Warning: Creating default object from empty value in /home/public/wp-content/plugins/wptouch/core/admin-load.php on line 106
Add artist to filename with AutoHotkey - Andrew Guyton's Blog

Andrew Guyton's Blog

A common task I’ve been using AutoHotkey for lately is adding the artist to the filename of an mp3. Here’s some quick code to do that:

RenameSongs(path, artist)
{
	Loop %path%\*.mp3
	{
		IfNotInString A_LoopFileName, %artist%
		{
			newfilename = %artist% - %A_LoopFileName%
			StringReplace newfilename, newfilename, (1),, All
			FileMove %path%\%A_LoopFileName%, %path%\%newfilename%
		}
	}
	TrayTip File rename,Done!
}

Then call it from somewhere else with a path and a proper artist name. How you do that part is up to you, I’m just plugging the values into the script. You could probably make an explorer keyboard shortcut and a box that prompts you for the artist name if you so desired.

2 Responses to “Add artist to filename with AutoHotkey”

  1. Tom

    I want to add the Artist to the start of the song filename for 1400+ .mp3 files that are in one directory but not on itunes. There is a different Artist in each files properties.

    I have never used script like this before. I am using Windows XP

    Please advise how I do it?

  2. Andrew Guyton

    I’m not exactly sure how to do that, but it sounds like a good thing to be able to do. I don’t see an immediately obvious method, so I might end up using COM or a Windows API call to extract the data from a file.

Leave a Reply

 

Powered by WordPress and theme developed using WordPress Theme Generator.
Copyright © Andrew Guyton. All rights reserved. Feeds: Entries (RSS) and Comments (RSS).