For years now I’ve had songs in my music collection that are so terrible I shudder when they come on – but the process of actually deleting the file so I’d never hear it again has always been so painful I never do it. So end up listening to the thing again and again.
Applications like iTunes, VLC and Windows Media Player all work the same way by deleting the song from the play list and not the file system itself. To delete from the file system you usually have to go through some complicated process to find the file path, open windows explorer and then delete it from there.
I’ve googled a bit over time for plugins and so on that let you actually delete the currently playing song but I’ve never really had much luck so thought I would bite the bullet and make something up.
I had grand plans of having a lovely little WPF application that sits in the system tray with an assigned keyboard hotkey to delete the currently playing song. I thought I would do this by just scanning the file handles the media playing application has hold of, find the mp3 / wma file and then delete it. Since .NET isn’t very capable at getting low level file handle information without going into a whole lot of unmanaged code I thought I would just use the output from the sysinternals Handle application. This needs administrative privileges however to run, and I subsequently found out that it is impossible to run an external process from .NET with elevated privileges (contrary to many posts around the internet) – on Windows 7 with UAC enabled anyway. This guy also found this out the hard way.
So I’m sorry, I didn’t end up making a pretty application but I did end up getting something going that works (a console application) – but is a bit geeky for the average user unfortunately.
However I thought I would share it anyway. Here are some steps to set it up:
- First of all, download DeleteCurrentlyPlaying.zip and extract to a directory. If you get an error when running it later, you may not have the .NET Framework 3.5 installed.
- Open a command prompt with Administrative rights. This guide tells you how to do this. On Windows XP you won’t need to worry about this.
- Navigate to the folder with the files in it e.g “cd c:\path\to\downloads\DeleteCurrentlyPlaying”
- Now run the following if your song is currently playing in Windows Media Player, VLC Player or iTunes respectively (this is just the process name changing):
handle –p wmplayer | DeleteCurrentlyPlaying
handle –p vlc | DeleteCurrentlyPlaying
handle –p itunes | DeleteCurrentlyPlaying
- For your piece of mind, the file isn’t actually deleted, it is moved to a subfolder “To Delete” for you to delete at some point. Also if you would rather download the source and compile it yourself, you can find it here.
The application will wait until the file has been released by the application before it is moved (in the case of Windows Media Player it seems it can be moved while it is being played).
It should look something like this:
You can just leave this console window open, and then hit the up arrow to repeat the last command and hit enter again when the next one to go comes on.
I have found a way to make execution of this slightly easier. Create a .bat file in the unzipped directory with the following contents:
handle –p wmplayer | DeleteCurrentlyPlaying (or replace wmplayer with whatever your music player process is)
Now, create a shortcut to this bat file and right click –> properties –> Shortcut –> Advanced –> Check “Run as administrator”.
The reason we need to cd to the unzipped dir in the batch file above is because when we run cmd as administrator it seems to ignore the “start in” directory and takes you to c:\windows\system32.
If you are using a productivity tool such as Launchy you can then create an entry direct to the shortcut using the Runner addin.