Move Music Into Artist Folders

I like my music in artist folders so I created this little VB Script to move music albums into single folders.
It takes a folder full of albums in the format “Artist – Album” and creates a folder for each artist, then moves the Albums into that folder.

For example if you have a folder C:\Music and sub folders in the format “Artist – Album” like below:

C:\Music\Artist1 – Album1
C:\Music\Artist1 – Album2
C:\Music\Artist2 – Album1

It will turn it into:

C:\Music\Artist1\Artits1 – Album1
C:\Music\Artist1\Artist1 – Album2
C:\Music\Artits2\Artits2 – Album1

Just copy the below code into a text file, rename it something like “music mover.vbs” put it in your root music directory (C:\Music\ in my example) and run it. Your music should now be in folders by artist.

Script is:

Dim fso, folderObj, folders, outputFile, currentDir, newFolder, dashPos, folderName

Set fso = CreateObject("Scripting.FileSystemObject")
currentDir = fso.GetAbsolutePathName(".") + "\"

Set outputFile = fso.CreateTextFile(currentDir&"\FileList.txt", True) 'file for loging things
Set folderObj = fso.GetFolder(currentDir)

Set folders = folderObj.SubFolders

For each folderIdx In folders
	newFolder = ""
	dashPos = InStr(folderIdx.Name, "-")
	folderName = currentDir + folderIdx.Name

	if dashPos <> 0 then 'we found a dash in the folder name (asuming that there are no artists or albums with dashes in their names the format is Artist - Album)

		newFolder = currentDir + Trim(Left(folderIdx.Name, dashPos-1))

		if not fso.FolderExists(newFolder) then
			outputFile.WriteLine("Created new folder (" + Trim(Left(folderIdx.Name, dashPos-1)) + ")")
			outputFile.WriteLine("Folder already exists (" + Trim(Left(folderIdx.Name, dashPos-1)) + ")")
		End If		

		outputFile.WriteLine(" - Added (" + folderIdx.Name + ")")
		Call fso.MoveFolder(folderName, newFolder + "\\")

	End If


If I feel like it I might write a script that does the opposite, takes Music\Artist\Artist – Album and moves them to Music\Artist – Album.


One Response

  1. Nice script. I’m picky about my music organization too.

    ~ C.H.
    Music news, artist reviews, and upcoming songs at the new Decibel Blog.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: