I cleaned up my mp3 collection - remove track numbers etc. Now I need to rename them

keithmct

Active Member
Joined
Mar 9, 2007
Messages
256
Office Version
  1. 2021
Platform
  1. Windows
Hi all, through some YouTube vids I have succeeded in listing all my mp3's from the music directory H:\Music. The full path shows in column F. Existing track name excluding file type extension is in column A. eg. 01 - Beethoven 9th symphony. New desired file name is in column B eg Beethoven 9th symphony, without file extension.
Subfolders of H:\Music are the usually artist name and sub-sub folders are the albums with the mp3 files. Sometime mp3's don't have an album and are just in the artist folder. Regardless, in column F, I need a way to substitute whatever is between the last backslash and .mp3 with the data in column B.
Thanks in advance
 
OK once I realised that I had fixed 10 songs in the experiment WB, I went back and amended the messy song list to not include those ones. ran the code again and it seemed to do something but mp3's still have track numbers in titles.
 
Upvote 0

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
OK, I guessed the new filenames were already present.
If you run the code for one where you know the number exists, add this line of code in after the line fso.MoveFile strOldSongPath, strNewSongPath

MsgBox "Old file (" & strOldSongPath & ") exists?: " & fso.FileExists(strOldSongPath) & vbCr _
& "New file (" & strNewSongPath & ") exists?: " & fso.FileExists(strNewSongPath)

You could put the code in twice, once before and once after i.e.

'Show that existing file is present, and new file isn't
MsgBox "Old file (" & strOldSongPath & ") exists?: " & fso.FileExists(strOldSongPath) & vbCr _
& "New file (" & strNewSongPath & ") exists?: " & fso.FileExists(strNewSongPath)
'Rename it if the existing fileexists and the new file doesn't
If fso.FileExists(strOldSongPath) And Not fso.FileExists(strNewSongPath) Then
fso.MoveFile strOldSongPath, strNewSongPath
Else
MsgBox "Either the existing file isn't found, or the new filename already exists (" & strOldSongPath & ")"
End If
'Show that existing file isn't present, and new file is
MsgBox "Old file (" & strOldSongPath & ") exists?: " & fso.FileExists(strOldSongPath) & vbCr _
& "New file (" & strNewSongPath & ") exists?: " & fso.FileExists(strNewSongPath)

Slight improvement in that it now checks that the existing file exists AND the new file doesn't.

If you aren't sure what is going on, add a watch to the new and old filename and as you step through you can see the values.

for testing you would be better off copying some of the fioles to a different location and running against those, then you can repalce the files each time until you get it right. As I said, it works for me with the list of files set up like yours, i.e. the new filenames are without the track number.

Thanks

Martin
 
Upvote 0
thanks very much. I'll test it as you suggest. Coming to the end of my tether on this project although you've done all the work.
I've also found utilities that will organise and rename mp3s properly based on tags and existing spotty information in song names/albums/artist/year of release etc and I'm seriously considering that route.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,175
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top