-1

I have thousands of episodes that I want to rename which are all in a similair format.

This would take a really long time if I had to do it manually.

So I'll need a simple way to batch rename the following examples:

[Source]SeriesName_-_001_EpisodeName_[480p][DVD][Uploader]

[Source]SeriesName_-_010_EpisodeName_[720p][BD][Uploader]

[Source]SeriesName_-_100_EpisodeName_[1080p][BD][Uploader]

to just:

SeriesName Episode 1 - EpisodeName

SeriesName Episode 10 - EpisodeName

SeriesName Episode 100 - EpisodeName

How would I be able to achieve this?

1 Answers1

1

I'd keep the constant episode number length for sorting reasons.

What about extensions (my one liner preserves them)?

In the command line:

for %F in ([*) do @for /f "tokens=2-4 delims=-_[]" %A in ("%F") do @echo Ren "%~fF" "%A Episode %B - %C%~xF"

Sample output:

Ren "Q:\Test\2018\04\05\[Source]SeriesName_-_001_EpisodeName_[480p][DVD][Uploader]" "SeriesName Episode 001 - EpisodeName"
Ren "Q:\Test\2018\04\05\[Source]SeriesName_-_100_EpisodeName_[1080p][BD][Uploader]" "SeriesName Episode 100 - EpisodeName"
Ren "Q:\Test\2018\04\05\[Source]SeriesName_-_010_EpisodeName_[720p][BD][Uploader]" "SeriesName Episode 010 - EpisodeName"

In a batch file double all the percent signs.

The first for iterates all items starting with a [
The second for splits the name at all specified delimiters (adjacent ones count as only one) taking only second to fourth. The ren command is only echoed for security reasons. Remove the echo if the output is OK.

EDIT: This batch file version removes leading zeroes:

:: SU1310869.cmd
@Echo off&SetLocal EnableExtensions EnableDelayedExpansion
:: cd /d "X:\folder\episodefiles
for %%F in ([*) do @for /f "tokens=2-4 delims=-_[]" %%A in ("%%F") do (
  set /a Num=1%%B - 1000
  @echo Ren "%%~fF" "%%A Episode !Num! - %%C%%~xF"
)
LotPings
  • 7,391