There is no "automatic" way to do that: you will first off have to do it in two stages: Find all zero length files delete them, then find all empty folders.
Zero length files isn't too bad:
Directory.GetAllFiles[
^] will return you a list of every file under a directory if you use the SearchOption.AllDirectories option.
You can then parse that list and check the file sizes by creating a
FileInfo[
^] for each file and checking the
FileInfo.Length[
^] property. It's then a simple matter to use
File.Delete[
^] to remove them.
Empty directories is harder, but not a lot. If while you are parsing the files above, you build a list of directories which contain at least one non-zero length file, you can compare that to the array returned by
Directory.GetDirectories[
^] and use
Directory.Delete[
^] to remove them - but...be careful! You do not want to remove a directory unless all it's subdirectories are empty as well! :laugh: