The Computer Oracle

Delete folders with many files quickly in WinSCP

--------------------------------------------------
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------

Music by Eric Matyas
https://www.soundimage.org
Track title: Peaceful Mind

--

Chapters
00:00 Delete Folders With Many Files Quickly In Winscp
00:22 Accepted Answer Score 13
01:32 Answer 2 Score 1
01:52 Thank you

--

Full question
https://superuser.com/questions/1053252/...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#winscp

#avk47



ACCEPTED ANSWER

Score 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




ANSWER 2

Score 1


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.