Jump to content

Help: A Way to automatic rename subtitle files

- - - - -

  • Please log in to reply
No replies to this topic

#1
bodosko

bodosko

    Newbie

  • Members
  • Pip
  • 1 posts
Hello, I need some help here.

In my dir I have two types of files, movies ".avi", and subtitles ".srt"
Players need that avi and srt filenames be the same, but subtitles never came with the same name of the movie filename. So I'm trying to make a script to rename automatic the .srt files to the corresponding movie filename.

For example, in my dir I have this files:
Pushing.Daisies.2x01.HDTV.XViD-DOT.srt

Pushing.Daisies.S02E01.HDTV.XViD-DOT.avi

Pushing.Daisies.S02E02.HDTV.XViD-DOT.avi

pushing.daisies.s02e02.hdtv.xvid-dot.srt

Pushing.Daisies.203.HDTV.XviD-NoTV.avi

Pushing.Daisies.S2E03.HDTV.XviD-NoTV.srt
I need them to be rename same way, like this:
Pushing.Daisies.S02E01.HDTV.XViD-DOT.srt

Pushing.Daisies.S02E01.HDTV.XViD-DOT.avi

Pushing.Daisies.S02E02.HDTV.XViD-DOT.avi

Pushing.Daisies.S02E02.HDTV.XVID-DOT.srt

Pushing.Daisies.S2E03.HDTV.XviD-NoTV.avi

Pushing.Daisies.S2E03.HDTV.XviD-NoTV.srt

I tryed using batch programming and pascal. Sice I know just the very basic of this two. But I got stuck on both :(

This is what I could made with batch:
@echo off

echo The following files were renamed:

for /F %%i in ('dir /b *.avi ^| findstr /i "S[0-9]*E[0-9]* [0-9][0-9][0-9] [0-9]x[0-9][0-9]"') do (

	echo %%i >> file

	for /F "tokens=1-3 delims=." %%a in ('findstr /i "S[0-9][0-9]E[0-9][0-9] [0-9][0-9][0-9] [0-9]x[0-9][0-9]" "file"') do (

		echo %%a >> temp

		echo %%b >> temp

		echo %%c >> temp

		echo %%d >> temp

		echo %%e >> temp

		echo %%f >> temp

		echo %%g >> temp

        	for /F %%m in ('findstr /i "S[0-9][0-9]E[0-9][0-9] [0-9][0-9][0-9] [0-9]x[0-9][0-9]" "temp"') do (

			for /F %%q in ('dir /b *.srt ^| findstr /i "%%m"') do ( 

				rename "%%~q" "%%~ni.srt"

				echo ------------------------------------------------------------------------------- "%%~q" - "%%~ni.srt"


			)

		)

	)

	del file

	del temp

)

pause
The problem is that when the part that represents season and episode of filename of the avi and srt are different, like *205*.srt and *S02E05*.avi
It doesn't work.
If I could set to a variable the exactly string that the FINDSTR command found, not the entire line(filename), I could make it. But I don't know how.

So, if somebody have an idea of code, or if there is a language that it's easier to make it, please help me.
Thanks!

And if I posted it in the wrong section, sorry. Im new on the forum.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users