11

In WinSCP, if I select a directory and right-click to delete, instead of simply deleting the directory it deletes all the contents one at a time. Depending on the contents and the connection, this can take a very long time.

Is there any way, within the WinSCP interface, I can simply delete a directory as quickly as if I'd used a command like rm -rf?

2 Answers2

13

This is based on the WinSCP "Useful commands" page entry for "delete" with some important missing steps added.

These steps you only need to do once:

  1. Right-click some test directory to delete
  2. Choose Custom commands > Customize
  3. Click the "Add" button
  4. Under "Description" give it a name of your choice, like "Delete"
  5. Under "Custom command" you have a choice:
    • Do you want a confirmation box to pop up? If so, enter: test "!?Do you really want to delete ?no!" == "yes" && rm -rf !&
    • Do you want it to just instantly delete? If so, enter: rm -f -r "!"
  6. Tick the "Apply to directories" checkbox
  7. Hit "Okay". You now have a "Delete" option under "Custom commands" any time you right-click a file or folder.

You can now delete any file or folder instantly with this new custom command. It might take a few seconds to reconnect the first time you do this in a session

0

Another solution is writing e.g. a PHP script and invoking the deletion from there: https://stackoverflow.com/questions/3338123

This will also allow you to delete a folder with essentially native code execution speed instead of the horrendous network overhead when deleting each individual file/folder.