5 Comments

I have a normal sized MP3 collection on my computer and I let Windows Media Player take care of arranging the MP3 and WMA files in the folders based on the media information in the ID3 tags. In my music folder, there is a folder per artist, and in each of them there is a folder per album which then contains the actual MP3 or WMA files. That adds up to a great number of folders.

When I delete a song from within Windows Media Player, the file is deleted from disk but the folder is not. Over time that leaves a lot of empty folders and folders that only contain album art. To look through all the folders to see if they could be deleted is too big a task, so I had to come up with a little C# program that could help me.

The program searches a given folder for empty subfolders or subfolders containing certain file types. It can also look for folders that don’t have certain file types which is exactly what I needed to clean my music library. It will iterate through all my music folders and remove those without any .mp3 or .wma files in it. You can define your own file types to search for or choose the predefined ones as you can see from the screenshot.

It doesn’t actually delete the folders; it just moves them to a new folder so nothing extremely unfortunate will happen. It does not remove system-, hidden- or read-only files and folders. After the folders have been moved, you can then delete them yourself.

The program Folder Cleaner requires .NET Framework 2.0. It is a standalone application that doesn’t need to be installed. Don’t worry, its virus and spyware free. The code is only 300 lines including comments. If you are interested in the source, just let me know. If enough people want it, then I'll add it to this post for everybody to download.

The program comes as is, and I can not be held responsible for its use. Use with caution.

Download

Folder Cleaner.zip (9,12 KB)

FolderCleanerSource.zip (113,55 KB)

Comments

Comment by  JMC

Sounds like a textbook example of using a shotgun to kill a fly. You could have easily done this with any scripting language (python, perl, ruby, etc.). Hell, even VBScript if you have a hardon for Microsoft.

JMC

Comment by  Mads Kristensen

JMC: I agree, but not all projects are strictly done to fulfill a purpose. Some are just fun to do, and this is a textbook example to use your own words. I had fun doing it, and it turned out pretty good and easy to use.