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
			fso.CreateFolder(newFolder)
			outputFile.WriteLine("Created new folder (" + Trim(Left(folderIdx.Name, dashPos-1)) + ")")
		else
			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
Next

outputFile.Close

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.