Link to home
Start Free TrialLog in
Avatar of ttist25
ttist25

asked on

Replacing and trimming characters in filenames using a batch file (windoze)

Good morning,

I'm trying to rename some mp3 files and would like to achieve two goals:

1.  I want to replace underscores with spaces
2.  I want to strip off leading track numbers

For example I would like to take the following filename:

"01 - This_Is_The_Title.mp3"

And convert it to:

"01 - This Is The Title.mp3"

And then to:

"This Is The Title.mp3"

The biggest problem is with stripping numbers off because they are not consistent.  For example, I have files like the following:

01This_Is_The_Title.mp3

and

01 - This_Is_The_Title.mp3

I could group similarly named files in directories without too much trouble to solve this and then hand sanitize the rest.

What do you think?
ASKER CERTIFIED SOLUTION
Avatar of Steve Knight
Steve Knight
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ttist25
ttist25

ASKER

Hey Dragon,

Thanks for your response.  I think we're almost there.  

Is it possible to separate these into two batch files?  1 that removes the _ and one that strips the first characters?  

I think I would better be able to understand and modify the batch file that way.  

Also, it's renaming the batch file itself.  How would we call to a directory other than root?

Thanks again for your help!
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ttist25

ASKER

Thanks for your response Qlemo it is greatly appreciated.

I get an error "The syntax of the command is incorrect" when I run this.

I'm using Vista if that makes any difference.
Remove the first line (@echo off), and try again. You should see the command causing that error message.

Above line 10 needs to be corrected, I forgot to quote because of the spaces:
for %%F in ("C:\MP3s\* - *.mp3") do (

Hi guys,  sorry for abondoing.  I offered my suggestions originally then wasn't online for the rest of the day then away for a weekend in Wales where the mobile internet signal is still steam driven 2G GPRS (which is better than no signal at all where I went last time I suppose...)

Anyway please let us know if you still need some more help and will be answer.

Steve