I've got a folder with a load of folders in folders in folders etc... Some of the folders have files, and some do not. I want to cleanup the main folder by finding all directories with no files and deleting them. An example might make more sense:
So if I start with this:
mainFolder
folder1
folder1
(empty)folder2
file.txt
folder3
(empty)
folder2
folder1
(empty)folder2
(empty)folder3
folder1
folder1
(empty)
folder3
folder1
file.txt
I should end up with this:
mainFolder
folder1
folder2
file.txt
folder3
folder1
file.txt
So:
/mainFolder/folder1/folder1
was deleted cause it had no files/mainFolder/folder1/folder3
was deleted cause it had no files/mainFolder/folder2
was deleted because cause it had no files, even all the sub-folders were empty
I hope this makes sense...
The only idea I had was to start at mainFolder
and recursively travel down each sub-folder deleting the ones that are empty.