0

I want to rename my TV shows as per the episode and the series they are from. My TV shows are generally in the format '[Show name].SabEyz.blabla.mp4', e.g, Futurama.S07E01.HDTVx264.mp4' I want to rename them in this format 'Episode xy - [Show name] - Series ab.mp4'

I tried using the following:

    for %%a in (*S07E??*.mp4) do ren '%%a' 'Episode ?? - Futurama - Series 7.mp4'

But it gave me an error that the specified file was not found

As you can see the above script cannot be used generally for all the series of the same show. I would like to do something about that too. Thank you!

  • 2
    First, you should change to real quotes `"%%~a"` instead of `'%%a'`. The `??` can't be used the way you tried it. You need more batch logic here – jeb Jun 25 '13 at 13:57
  • 1
    try the [Advanced Renamer](http://www.advancedrenamer.com/), best renamer for video files! :T – Endoro Jun 25 '13 at 14:05

2 Answers2

2
@echo off
setlocal EnableDelayedExpansion

for /F "tokens=1,2* delims=." %%a in ('dir /B *.mp4') do (
   set sXXeYY=%%b
   ren "%%a.%%b.%%c" "Episode !sXXeYY:~4,2! - %%a - Series !sXXeYY:~1,2!.mp4"
)
Aacini
  • 65,180
  • 12
  • 72
  • 108
0
@ECHO OFF
SETLOCAL enabledelayedexpansion
FOR /f "tokens=1-3delims=." %%i IN ('dir /b/a-d *.*.*.mp4') DO (
 SET seriesep=%%j
 SET /a series=1!seriesep:~1,2! - 100
 SET /a episode=1!seriesep:~-2! - 100
 ECHO REN "%%i.%%j.%%k.mp4" "Episode !episode! - %%i - Series !series!.mp4"
)
GOTO :EOF

This should do the rename as specified - well, it'll ECHO the rename command to the screen - remove the ECHO keyword to activate the rename.

Not sure whether you want to retain or suppress the leading 0s. If you want to retain them, change (eg)

 SET /a series=1!seriesep:~1,2! - 100

to

 SET series=!seriesep:~1,2!

OR

substitute !seriesep:~1,2! for !series! in the [echo] REN line.

Magoo
  • 77,302
  • 8
  • 62
  • 84