1

I never thought I'm gonna need such a program and always wondered how one can come into a situation where he has many empty folders and wants to delete them. Now, I'm in that situation: I have deduplicated a history of backups from 2013 to 2020, i.e. deleted all identical files. That gave me ~2.3 TB of free storage, but the directories remained.

I'm looking for a program that deletes empty directories. A directory may count as empty if it contains other empty directories only.

Now I thought that this is a trivial task, but it seems I was totally wrong. I have a disk with 240.000 empty folders and I tried:

  • RED - Remove Empty Directories. This tool has a nice UI, but is unresponsive during the scanning process. By default it delays 80ms between deleting a directory, which slows down my case to 5:20 hours. That's not acceptable. I reduced that time to 0 ms. But in fact it was only able to delete 1 directory per second! When cancelling the operation, one needs to go through the scanning phase again. Argh!
  • Empty Folder Nuker also needs a long time to find empty directories. It only displayed ~8000 of those 240.000 directories. Why did it take so long to scan them then?
  • WizTree is very fast and tells me that I have 240.000 directories on my hard disk and only about 5000 files. But it has no option to delete empty directories.

I don't want:

  • programming it myself, so please no programming language suggestions

So please, if you have successfully deleted 100.000 empty folders with some tool and you were happy with it, please share it with me. Do not google for results. That's what I did.

5
  • 1
    Is a Powershell command considered programming? there is an effective solution using that. – user10191234 Nov 14 '20 at 7:08
  • Good question. I removed it because the community typically uses that tag when online solutions are common or available, but they want an offline solution. For your situation, as you mentioned, only a very contrived solution would have you uploading all your 240,000 empty folders to the cloud just to delete them! :-) – RockPaperLz- Mask it or Casket Nov 16 '20 at 9:40
  • Our conversation made me think of a possible solution for you. About how large are the 5000 files, and would you be willing to use a tool that would copy them to another local partition (or drive) as part of the solution? If so, I can check a couple backup tools I use to see if one of them might be able to do the job. Even if they claim to be able to not copy empty folders, I can't promise anything because, well, I have never had 240,000 empty folders. You've piqued my curiosity... how did that happen? – RockPaperLz- Mask it or Casket Nov 16 '20 at 9:47
  • @RockPaperLz-MaskitorCasket: I added that to the question. I deduplicated 7 years of backups, so all duplicate files were removed - but the directories remained. The remaining size is 700 GB. A few large files and many smaller ones. - copying that will take more than 2 hours. My new backup solution will deduplicate right away, – Thomas Weller Nov 16 '20 at 10:00
  • How many levels deep is the deepest level in the directory tree? – RockPaperLz- Mask it or Casket Nov 17 '20 at 0:18
0

Using Powershell.

Go to the parent folder where you'd like to delete its empty childs and type:

ROBOCOPY . . /s /move

3
  • How is robocopy related to Powershell? – Thomas Weller Nov 14 '20 at 22:28
  • Ok, that is "move all files from here to here except the empty ones". Sounds like a quite dangerous command. Not sure if that usage was intended. How did you find this? Is it guaranteed to work also in future versions of RoboCopy? – Thomas Weller Nov 14 '20 at 22:31
  • You're right, it can also work in CMD but I am used to PS, anyway, you could try it before, create a folder containing disposable empty and populated subfolders and files and run it from that folder, you'll see the result. And wouldn't it work in future robocopy version, its only parameters are /s and /move and I do not believe they will remove them soon. – user10191234 Nov 14 '20 at 23:14
0

A rough and ready tool for doing this is available as rmmpty_tree - it is written in Python 3.8 then built using pyinstaller into a windows 64 bit executable.

Not the fastest nor the most pretty but it will show you which directories are left behind because of existing files.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.