Batch script to auto rename subtitles files

June 16, 2009 at 21:40:23
Specs: Windows XP
Hello, I need some help here ;D

I have two types of files in my dir,
movies > .avi
subtitles > .srt

But for the player to show the correct subtitles, the subtitle filename must be same as movie filename, except for the extension.

So I'm trying to make a batch script that auto rename the .srt files to it corresponding movie filename.

For example, I have this files in my dir:

pd.201.xvid-notv.srt
Pushing.Daisies.S02E01.HDTV.XViD-DOT.avi
Pushing.Daisies.S02E02.HDTV.XViD-DOT.avi
pushing.daisies.s02e02.hdtv.xvid-dot.srt
Pushing.Daisies.S02E09.HDTV.XviD-2HD.avi
Pushing.Daisies.S02E09.The.Legend.Of.Merle.McQuoddy.HDTV.XviD-2HD.srt

So...

"pd.203.xvid-notv.srt"
must be renamed to "Pushing.Daisies.S02E01.HDTV.XViD-DOT.srt"

"pushing.daisies.s02e02.hdtv.xvid-dot.srt"
to "Pushing.Daisies.S02E02.HDTV.XViD-DOT.srt"

"Pushing.Daisies.S02E09.The.Legend.Of.Merle.McQuoddy.HDTV.XviD-2HD.srt"
to "Pushing.Daisies.S02E09.HDTV.XviD-2HD.srt"

Can you help me please? Thanks


See More: Batch script to auto rename subtitles files

Report •


#1
June 17, 2009 at 00:04:51
eduedp, seems to me you could have it read each filename and set it = a variable. Then have it 'test' the variable name and change it if incorrect, then on to the next file, etc. Since it'd occur at machine speed, it'd be very fast.
HTH.
Ed in Texas.


Report •

#2
June 17, 2009 at 00:26:37
Well I'm almost done with this one.
But I still have a problem. See the ***coments in the batch code

for /F %%a in ('dir /b *.avi ^| findstr /i "S[0-9]*E[0-9]*"')  do (
	for /F %%b in ('dir /b *.srt ^| findstr /i "***the string "SnnEnn" found in last findstr***"')  do ( 
		echo "%%~b"
		echo rename "%%~b" "%%~na.srt"
	)
)
pause

How can I make it? Store only the found string(not the entire line,filename) to a variable to use it later.


Report •

#3
June 19, 2009 at 01:28:52
Thanks for sharing. it's great.

[url=http://pret-auto.org][color=#FFFFFF][u]pret auto[/u][/color][/url]


Report •

Related Solutions


Ask Question