Link to home
Start Free TrialLog in
Avatar of Bill Golden
Bill GoldenFlag for United States of America

asked on

Batch Renaming of Files

Amazon Music, for reasons only know to them, downloads the following file

          Mason Williams - Change the World.MP3

renaming the files during download as follows:

          01-02- Change the World.MP3

I know restoring the artist's name is going to be difficult, but how do I batch rename...

          01-02- Change the World.MP3     to     Change the World.MP3
          01-04- Hello, Goodbye.MP3          to     Hello, Goodbye.MP3
          02-02- Ticket to Ride.MP3             to      Ticket to Ride.MP3

In other words, stripping the 0?-0?-   from the front-end of the filename.

I have tried several iterations of REN such as REN  "0?-0?-*.MP3"  "*.MP3",  but nothing I do seems to work. Suggestions?
Avatar of Shaun Vermaak
Shaun Vermaak
Flag of Australia image

Use this Powershell command. Remove -WhatIf to run for real
$RegEx = '\d{2}-\d{2}- (?<Name>.+?)\Z'
Get-ChildItem -Path 'C:\Temp\ren' -Filter *.mp3 | Where-Object {$_.BaseName -match $RegEx} | ForEach-Object {
	Rename-Item $_.FullName -NewName "$($Matches['Name'].Replace('.', ' '))$($_.Extension)" -WhatIf
}

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Shaun Vermaak
Shaun Vermaak
Flag of Australia 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
No, ren with wildcards will not d. It can only replace parts of same length, or add extensions  etc.
You'll need a loop in a batch file:
@echo 
setlocal EnableDelayedExpansion
pushd C:\Music\
for %%n in "*-*-*.mp3") do (
  set name=%%~n
  ren !name! !name:~7!
)

Open in new window

This cuts of the first 7 characters of the name, if it contains at least two dashes.
Avatar of Bill Golden

ASKER

Shaun, Qlermo, I could not get either routine to work.
However Shaun, the ID3 Renamer re-directed me to ID3 Tag Editor which solved both problems at the same time.
Avatar of tulpan vadim
tulpan vadim

I suggest to try KrojamSoft BatchRename