Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Making Filenames Mirror One Another With Different Extensions

53 views
Skip to first unread message

AlleyCat

unread,
Jan 17, 2016, 5:20:43 PM1/17/16
to

Hello all. I think this will be simple for you batch and script gurus, but
it's driving me crazy.

Videofile: House.S08E18.Body And Soul.mkv

Subtitle: House.S08E18.HDTV.XviD-LOL.srt

If you please... copy text after third period (or whatever will be before
the extension in other cases) of videofile and copy it to the srt file, so
both files are identical other than the extension.

Sample: House.S08E18.Body And Soul.mkv
House.S08E18.Body And Soul.srt

Not all vid files are in this "format", but I'll work on it from there.

Thank you so very much.

foxidrive

unread,
Jan 18, 2016, 9:41:10 AM1/18/16
to
This was crossposted to various places.

On 18/01/2016 09:20, AlleyCat wrote:
> >
> > Videofile: House.S08E18.Body And Soul.mkv
> > Subtitle: House.S08E18.HDTV.XviD-LOL.srt
> >
> > so both files are identical other than the extension.
> >
> > Sample: House.S08E18.Body And Soul.mkv
> > House.S08E18.Body And Soul.srt


This can be done by using the initial term "House.S08E18" and isn't so hard.
Run this script in an empty folder - it creates the sample files to test it
with.

The ren command is only printed to the console at present - you can remove
the 'echo' to make it perform the rename.


@echo off
break>"House.S08E18.Body And Soul.mkv"
break>"House.S08E18.HDTV.XviD-LOL.srt"

for %%a in ("house*.mkv") do (
for /f "tokens=1,2 delims=." %%b in ("%%~a") do (
for %%d in ("%%b.%%c*.srt") do echo ren "%%~d" "%%~na%%~xd"
))
pause


The difficulty is in the various format of the files.

JJ

unread,
Jan 18, 2016, 10:40:01 AM1/18/16
to
It's pretty complicated considering the format can be anything. Try below
code. Use code from the pastebin link if your news client always split long
lines.

<http://pastebin.com/4Ajrgiak>

The code relies heavily on the well known episode numbering format "SxxEyy".
It must be in the proper numbers. e.g. no season/episode zero. It assumes
that the text before that is the video title. It'll use both as a prefix
with period or a space separator based file naming. Text after the episode
are ignored. If two or more video files matched, only the first one is used.

e.g. for these files:

House S08E18 Body And Soul.mkv
House.S08E18.HDTV.XviD-LOL.srt
House.S08E18.Body And Soul.H264-LMAO.mkv
House.S08E18.HDTV.XviD-LOL.srt

The srt will be renamed as:

House S08E18 Body And Soul.srt

The actual REN command in the batch file is disabled. It simply show the REN
command line that should be executed.


@echo off
setlocal enabledelayedexpansion
pushd
if "%~1" == "" (
echo Usage: SyncSrtFileNames {folder}
goto :eof
)
cd /d "%~1"
if not errorlevel 0 (
echo Path is not accessible.
goto :eof
)
for %%A in (*.srt) do (
set fname=%%A
set fext=%%~xA
set processed=0
for /f "tokens=1-30 delims=." %%B in ("%%A") do (
call :getprefix "%%B" "%%C" "%%D" "%%E" "%%F" "%%G" "%%H" "%%I" "%%J"
"%%K" "%%L" "%%M" "%%N" "%%O" "%%P" "%%Q" "%%R" "%%S" "%%T" "%%U" "%%V"
"%%W" "%%X" "%%Y" "%%Z" "%%[" "%%\" "%%]" "%%^^" "%%_"
)
if !processed! == 0 (
for /f "tokens=1-30 delims= " %%B in ("%%A") do (
call :getprefix "%%B" "%%C" "%%D" "%%E" "%%F" "%%G" "%%H" "%%I" "%%J"
"%%K" "%%L" "%%M" "%%N" "%%O" "%%P" "%%Q" "%%R" "%%S" "%%T" "%%U" "%%V"
"%%W" "%%X" "%%Y" "%%Z" "%%[" "%%\" "%%]" "%%^^" "%%_"
)
)
)
goto :eof

:getprefix
set eps=
set prefix=
set separator=.
call :gploop %*
set eps=
set prefix=
set "separator= "
call :gploop %*
goto :eof

:gploop
if "%~1" == "" goto :eof
set ch=%~1
call :chkeps %ch:~0,1% %ch:~1,1% %ch:~2,1% %ch:~3,1% %ch:~4,1% %ch:~5,1%
%ch:~6,1%
if "%prefix%" == "" (
set prefix=%~1
) else (
set prefix=%prefix%%separator%%~1
)
if not "%eps%" == "" (
if not "%prefix%" == "" (
for %%B in ("%prefix%*") do (
if !processed! == 0 if not "%%~B" == "%fname%" (
echo dummy: ren "%fname%" "%%~nB%!fext!"
set processed=1
)
)
)
goto :eof
)
shift
goto :gploop

:chkeps
if not "%7" == "" goto :eof
if /i not "%1" == "s" goto :eof
set /a num=(%2*10)+%3
if !num! == 0 goto :eof
if /i not "%4" == "e" goto :eof
set /a num=(%5*10)+%6
if !num! == 0 goto :eof
set eps=%ch%

AlleyCat

unread,
Jan 18, 2016, 5:20:01 PM1/18/16
to

On Tue, 19 Jan 2016 01:41:08 +1100, foxidrive says...

> @echo off
> break>"House.S08E18.Body And Soul.mkv"
> break>"House.S08E18.HDTV.XviD-LOL.srt"
>
> for %%a in ("house*.mkv") do (
> for /f "tokens=1,2 delims=." %%b in ("%%~a") do (
> for %%d in ("%%b.%%c*.srt") do echo ren "%%~d" "%%~na%%~xd"
> ))
> pause
>
>
> The difficulty is in the various format of the files.

Thank you SO much!

for %%a in ("house*.mkv") do (
for /f "tokens=1,2 delims=." %%b in ("%%~a") do (
for %%d in ("%%b.%%c*.srt") do ren "%%~d" "%%~na%%~xd"))

Pared it down to this and it works great. Thank you, very much!

AlleyCat

unread,
Jan 18, 2016, 5:26:11 PM1/18/16
to

On Mon, 18 Jan 2016 22:39:59 +0700, JJ says...
Wow... thank you very much!

AlleyCat

unread,
Jan 18, 2016, 8:31:00 PM1/18/16
to

Not all files, either the video OR the subtitle files, come in that
particular format. Some might look like this:

House.S08E18.Body And Soul.mkv

House.MD.S08E18.HDTV.XviD-LOL.srt

What I'd really like, is to match files that have the same season and
episode, and change the srt (subtitle) file to match the video file.

Even if the srt ONLY has the season and episode disignation, I'd like it
to match with the video file and rename.

I realize it HAS to be hard to get a batch file to look at the whole
directory, compare files and pick out the ones with matching "SxxExx"'s
and rename the srt file only.

Video file: House.S08E18.Body And Soul.mkv

Subtitle file: S08E03.srt

to House.S08E18.Body And Soul.srt

Just need them to match for subtitle to work.

I've already finished the project I'm on now, so please... do NOT take
time out to do this unless you WANT to.

If you could make that work, you could probably SELL that script or batch
to pirates like me! LOL

Thanks again.

Todd Vargo

unread,
Jan 18, 2016, 11:26:50 PM1/18/16
to
S08E18 does not match S08E03. Originally, you posted matching examples.
Now they don't match. Did you make a typo in this Subtitle example?

--
Todd Vargo
(Post questions to group only. Remove "z" to email personal messages)

AlleyCat

unread,
Jan 19, 2016, 12:30:20 AM1/19/16
to

On Mon, 18 Jan 2016 23:26:49 -0500, Todd Vargo says...

> S08E18 does not match S08E03. Originally, you posted matching examples.
> Now they don't match. Did you make a typo in this Subtitle example?
>

LOL... yes. I was copying pasting and wanted to use a different example
than S08E18, and forgot to use the srt version of S08E03.

Sorry.

Todd, do you think it's possible for a batch file/script to search a
folder and see like files and rename the srt to match the mkv?

Hell, I'd settle for a mini program compiled to do it. I've got a friend
who writes code, but he's too busy with his life. LOL

foxidrive

unread,
Jan 19, 2016, 5:41:46 AM1/19/16
to
On 19/01/2016 16:30, AlleyCat wrote:
> Todd, do you think it's possible for a batch file/script to search a
> folder and see like files and rename the srt to match the mkv?

Is this project still underway then?

Would this be run in a folder with videos of only one single show?

Todd Vargo

unread,
Jan 19, 2016, 10:53:26 PM1/19/16
to
I wouldn't hazard to guess based on the few filenames provided so far.
With a more extensive list it might be possible to provide one with some
degree of reliability.

In your example
:
House.S08E18.Body And Soul.mkv



Is the .SxxExx. part always the second token?

Will the first token (House) always be a single word?

Did the code from either foxi or JJ do everything that you needed? If
not, what issues are you experiencing?


The following is a single line that may do what you want based solely on
what is known so far. The ECHO disables the rename command. If the
output looks correct, remove the ECHO to enable. I suggest you test it
on a test folder first.

for %a in (*.S??E??.*.mkv) do for /f "tokens=1-2 delims=." %A in ("%a")
do ECHO ren "%A.%B.*.srt" "%~na.srt"

AlleyCat

unread,
Jan 20, 2016, 2:54:28 AM1/20/16
to

On Tue, 19 Jan 2016 21:41:44 +1100, foxidrive says...

>
> On 19/01/2016 16:30, AlleyCat wrote:
> > Todd, do you think it's possible for a batch file/script to search a
> > folder and see like files and rename the srt to match the mkv?
>
> Is this project still underway then?

Not at the moment... the script you sent worked perfectly, for THESE
files. Like I said though, at some time I'm going to have files that
aren't so "alike", meaning they will most likely have ONLY the SxxExx in
common, and that is hopeful, but that's USUALLY the standard.

This could be the video file: House.S08E11.Nobody's Fault.xxx
And this could be the subtitle file: S08E11.House.srt

I would need for the script to find "x", x being the SxxExx, and rename
the srt file to match the vid file.

> Would this be run in a folder with videos of only one single show?

Show yes... ONE show (episode)? LOL... oh hell no... if it was only one
show (episode) and subtitle, I'd rename it myself. This could involve, in
this case anyways, 8 seasons of 20-24 episodes with corresponding subtitle
files, that aren't always named the same way.

I would never mix different shows in the same folder, so there won't ever
be duplicate SxxExx's in the same folder.


Example: Season 8 of House MD

House.S08E01.HDTV.XviD-LOL.srt
House.S08E01.Twenty Vicodin.mkv

House.S08E02.HDTV.XviD-LOL.srt
House.S08E02.Transplant.mkv

House.S08E03.Charity Case.mkv
House.S08E03.HDTV.XviD-LOL.srt

House.S08E04.HDTV.XviD-LOL.srt
House.S08E04.Risky Business.mkv

House.S08E05.HDTV.XviD-LOL.srt
House.S08E05.The Confession.mkv

House.S08E06.HDTV.XviD-LOL.srt
House.S08E06.Parents.mkv

House.S08E07.Dead and Buried.mkv
House.S08E07.HDTV.XviD-LOL.srt

House.S08E08.HDTV.XviD-LOL.srt
House.S08E08.Perils of Paranoia.mkv

House.S08E09.Better Half.mkv
House.S08E09.HDTV.XviD-LOL.srt

House.S08E10.HDTV.XviD-LOL.srt
House.S08E10.Runaways.mkv

House.S08E11.HDTV.XviD-LOL.srt
House.S08E11.Nobody's Fault.mkv

House.S08E12.Chase.mkv
House.S08E12.HDTV.XviD-LOL.srt

House.S08E13.HDTV.XviD-LOL.srt
House.S08E13.Man Of The House.mkv

House.S08E14.HDTV.XviD-LOL.srt
House.S08E14.Love Is Blind.mkv

House.S08E15.Blowing The Whistle.mkv
House.S08E15.HDTV.XviD-LOL.srt

House.S08E16.Gut Check.mkv
House.S08E16.HDTV.XviD-LOL.srt

House.S08E17.HDTV.XviD-LOL.srt
House.S08E17.We Need The Eggs.mkv

House.S08E18.Body And Soul.mkv
House.S08E18.HDTV.XviD-LOL.srt

House.S08E19.HDTV.XviD-LOL.srt
House.S08E19.The C Word.mkv

House.S08E20 Post Mortem.mkv
House.S08E20.HDTV.XviD-LOL.srt

House.S08E21.HDTV.XviD-LOL.srt
House.S08E21.Holding On.mkv

House.S08E22.Everybody Dies.mkv
House.S08E22.HDTV.XviD-LOL.srt

House.S08E23.Special-Swan.Song.HDTV.x264-BAJSKORV.srt
House.S08E23.Special-Swan Song.mkv



THAT is what I started with. THIS is after running:

@echo off
cls
for %%a in ("house*.mkv") do (
for /f "tokens=1,2 delims=." %%b in ("%%~a") do (
for %%d in ("%%b.%%c*.srt") do ren "%%~d" "%%~na%%~xd"))



House.S08E01.Twenty Vicodin.mkv
House.S08E01.Twenty Vicodin.srt

House.S08E02.Transplant.mkv
House.S08E02.Transplant.srt

House.S08E03.Charity Case.mkv
House.S08E03.Charity Case.srt

House.S08E04.Risky Business.mkv
House.S08E04.Risky Business.srt

House.S08E05.The Confession.mkv
House.S08E05.The Confession.srt

House.S08E06.Parents.mkv
House.S08E06.Parents.srt

House.S08E07.Dead and Buried.mkv
House.S08E07.Dead and Buried.srt

House.S08E08.Perils of Paranoia.mkv
House.S08E08.Perils of Paranoia.srt

House.S08E09.Better Half.mkv
House.S08E09.Better Half.srt

House.S08E10.Runaways.mkv
House.S08E10.Runaways.srt

House.S08E11.Nobody's Fault.mkv
House.S08E11.Nobody's Fault.srt

House.S08E12.Chase.mkv
House.S08E12.Chase.srt

House.S08E13.Man Of The House.mkv
House.S08E13.Man Of The House.srt

House.S08E14.Love Is Blind.mkv
House.S08E14.Love Is Blind.srt

House.S08E15.Blowing The Whistle.mkv
House.S08E15.Blowing The Whistle.srt

House.S08E16.Gut Check.mkv
House.S08E16.Gut Check.srt

House.S08E17.We Need The Eggs.mkv
House.S08E17.We Need The Eggs.srt

House.S08E18.Body And Soul.mkv
House.S08E18.Body And Soul.srt

House.S08E19.The C Word.mkv
House.S08E19.The C Word.srt

House.S08E20 Post Mortem.mkv
House.S08E20.HDTV.XviD-LOL.srt

House.S08E21.Holding On.mkv
House.S08E21.Holding On.srt

House.S08E22.Everybody Dies.mkv
House.S08E22.Everybody Dies.srt

House.S08E23.Special-Swan Song.mkv
House.S08E23.Special-Swan Song.srt

Thanks for that!












AlleyCat

unread,
Jan 20, 2016, 3:11:39 AM1/20/16
to

On Tue, 19 Jan 2016 22:53:25 -0500, Todd Vargo says...

> I wouldn't hazard to guess based on the few filenames provided so far.
> With a more extensive list it might be possible to provide one with some
> degree of reliability.
>
> In your example
> :
> House.S08E18.Body And Soul.mkv

> Is the .SxxExx. part always the second token?

No... if at all possible, I need the script to look for the SxxExx of all
files and then match up the "like" files, one .vid and one .srt, THEN
rename the .srt to match the .vid name exactly, other than the extension.

> Will the first token (House) always be a single word?

No. There might not even BE a "token". It's need to match the SxxExx's up.

Here is the contents of the folder "as is", before I ran foxidrive's
script.
***************************

At some time I'm going to have files that aren't so "alike", meaning they
will most likely have ONLY the SxxExx in common, and that is hopeful, but
that's USUALLY the standard.

This could be the video file: House.S08E11.Nobody's Fault.xxx
And this could be the subtitle file: S08E11.House.srt

I would need for the script to find "x", x being the SxxExx, and rename
the srt file to match the vid file.

***************************

THIS is after running:

@echo off
cls
for %%a in ("house*.mkv") do (
for /f "tokens=1,2 delims=." %%b in ("%%~a") do (
House.S08E18.Body And Soul.mkv
House.S08E18.Body And Soul.srt

House.S08E19.The C Word.mkv
House.S08E19.The C Word.srt

House.S08E20 Post Mortem.mkv
House.S08E20.HDTV.XviD-LOL.srt

House.S08E21.Holding On.mkv
House.S08E21.Holding On.srt

House.S08E22.Everybody Dies.mkv
House.S08E22.Everybody Dies.srt

House.S08E23.Special-Swan Song.mkv
House.S08E23.Special-Swan Song.srt


> Did the code from either foxi or JJ do everything that you needed? If
> not, what issues are you experiencing?

What foxi sent worked well, but...

> The following is a single line that may do what you want based solely on
> what is known so far. The ECHO disables the rename command. If the
> output looks correct, remove the ECHO to enable. I suggest you test it
> on a test folder first.
>
> for %a in (*.S??E??.*.mkv) do for /f "tokens=1-2 delims=." %A in ("%a")
> do ECHO ren "%A.%B.*.srt" "%~na.srt"

A was unexpected at this time.

H:\DVD's\House Season 8\Test>for A in ("A.~na.srt"

H:\DVD's\House Season 8\Test>test

Thanks.

foxidrive

unread,
Jan 20, 2016, 4:25:10 AM1/20/16
to
On 20/01/2016 18:54, AlleyCat wrote:

>> Is this project still underway then?
>
> Not at the moment... the script you sent worked perfectly, for THESE
> files. Like I said though, at some time I'm going to have files that
> aren't so "alike", meaning they will most likely have ONLY the SxxExx in
> common, and that is hopeful, but that's USUALLY the standard.

This is quite easy with a batch script called jrepl.bat - See later how to
get that.

When doing this kind of task it can be a mess and a headache if something
goes pear-shaped, so this script creates a temporary-batch-file that will
do the renaming AFTER you check it, and then you run the temporary script
manually.

It creates "+temp.bat.txt" which sorts to the top of the folder usually,
with the plus sign there.

@echo off
set files=*.mkv *.avi *.mov *.mp4 *.mpg
set jrepl=jrepl "(.*)(S[0-9][0-9]E[0-9][0-9])(.*)" "$1|$2|$3" /i /a
(
for %%a in (%files%) do (
for /f "tokens=1-3 delims=|" %%b in ('echo(%%a^|%jrepl%') do (
if exist "*%%c*.srt" echo ren "*%%c*.srt" "%%~na%.srt"
)))>+temp.bat.txt
pause


This uses a native Windows batch script called Jrepl.bat written by
dbenham, which uses jscript to make it very robust and swift.
http://www.dostips.com/forum/viewtopic.php?f=3&t=6044

Place Jrepl.bat in the same folder as the batch file, or in a folder that
is on the system path.


There is also copy on Dropbox (unblock it after downloading):
https://www.dropbox.com/s/4otci4d4s8x5ni4/Jrepl.bat




This script below creates the sample files that I tested this with - run it
in an empty folder.



@echo off
for %%a in (
) do break >"%%a"



AlleyCat

unread,
Jan 20, 2016, 8:20:17 PM1/20/16
to

Worked like a charm... thank you!

AlleyCat

unread,
Jan 20, 2016, 8:42:28 PM1/20/16
to

On Wed, 20 Jan 2016 20:25:04 +1100, foxidrive says...

> It creates "+temp.bat.txt" which sorts to the top of the folder usually,
> with the plus sign there.
>
> @echo off
> set files=*.mkv *.avi *.mov *.mp4 *.mpg
> set jrepl=jrepl "(.*)(S[0-9][0-9]E[0-9][0-9])(.*)" "$1|$2|$3" /i /a
> (
> for %%a in (%files%) do (
> for /f "tokens=1-3 delims=|" %%b in ('echo(%%a^|%jrepl%') do (
> if exist "*%%c*.srt" echo ren "*%%c*.srt" "%%~na%.srt"
> )))>+temp.bat.txt
> pause
>

Sorry, I jumped the gun... I renamed the video files, taking out "House"
and left just the SxxExx and the episode name, and the batch file did not
return anything to rename.

S08E15.Blowing The Whistle.mkv
and
House.S08E15.HDTV.XviD-LOL.srt

I was hoping the batch files could scan the folder, find duplicate partial
filenames and rename accordingly.

If ANY of your code needs to NOT look like the above, let me know, since
my newsreader is wrapping the lines at 75 characters.

Thanks.

AlleyCat

unread,
Jan 20, 2016, 8:45:29 PM1/20/16
to

On Wed, 20 Jan 2016 20:25:04 +1100, foxidrive says...

> @echo off
> set files=*.mkv *.avi *.mov *.mp4 *.mpg
> set jrepl=jrepl "(.*)(S[0-9][0-9]E[0-9][0-9])(.*)" "$1|$2|$3" /i /a
> (
> for %%a in (%files%) do (
> for /f "tokens=1-3 delims=|" %%b in ('echo(%%a^|%jrepl%') do (
> if exist "*%%c*.srt" echo ren "*%%c*.srt" "%%~na%.srt"
> )))>+temp.bat.txt
> pause
>

It seems to be working except when I rename the vid file. I WILL come
across that... vid files named "xxxx.S01E01.mkv" or just S01E01.mkv

Thanks for your help. If i have a problem in future projects, I will call
upon your expertise again.

foxidrive

unread,
Jan 20, 2016, 10:21:51 PM1/20/16
to
On 21/01/2016 12:45, AlleyCat wrote:
>
> On Wed, 20 Jan 2016 20:25:04 +1100, foxidrive says...
>
>> @echo off
>> set files=*.mkv *.avi *.mov *.mp4 *.mpg
>> set jrepl=jrepl "(.*)(S[0-9][0-9]E[0-9][0-9])(.*)" "$1|$2|$3" /i /a
>> (
>> for %%a in (%files%) do (
>> for /f "tokens=1-3 delims=|" %%b in ('echo(%%a^|%jrepl%') do (
>> if exist "*%%c*.srt" echo ren "*%%c*.srt" "%%~na%.srt"
>> )))>+temp.bat.txt
>> pause
>>
>
> It seems to be working except when I rename the vid file. I WILL come
> across that... vid files named "xxxx.S01E01.mkv" or just S01E01.mkv
>
> Thanks for your help.

No worries. The solution is even simpler.

@echo off
set files=*.mkv *.avi *.mov *.mp4 *.mpg
set jrepl=jrepl ".*(S[0-9][0-9]E[0-9][0-9]).*" "$1" /i /a
(
for %%a in (%files%) do (
for /f %%b in ('echo(%%a^|%jrepl%') do (
if exist "*%%b*.srt" echo ren "*%%b*.srt" "%%~na.srt"
)))>"+.bat.txt"
pause

I tested it with these filenames:

S01E01.mkv
S01E02.srt
xx.S01E01.what a day for a daydream.srt
xxxx.S01E02.mkv

and it gave me this:

S01E01.mkv
S01E01.srt
xxxx.S01E02.mkv
xxxx.S01E02.srt


Todd Vargo

unread,
Jan 20, 2016, 10:28:16 PM1/20/16
to
On 1/20/2016 3:11 AM, AlleyCat wrote:
>
> On Tue, 19 Jan 2016 22:53:25 -0500, Todd Vargo says...
>
<snip>
>> The following is a single line that may do what you want based solely on
>> what is known so far. The ECHO disables the rename command. If the
>> output looks correct, remove the ECHO to enable. I suggest you test it
>> on a test folder first.
>>
>> for %a in (*.S??E??.*.mkv) do for /f "tokens=1-2 delims=." %A in ("%a")
>> do ECHO ren "%A.%B.*.srt" "%~na.srt"
>
> A was unexpected at this time.
>
> H:\DVD's\House Season 8\Test>for A in ("A.~na.srt"
>
> H:\DVD's\House Season 8\Test>test


The single line was intended to be run from the command line. To use in
a batch file you must first double all of the % symbols.

Anyway, it looks like foxi has the new format covered so I'm done.

AlleyCat

unread,
Jan 20, 2016, 10:38:42 PM1/20/16
to

On Thu, 21 Jan 2016 14:21:48 +1100, foxidrive says...
I'm guessing you didn't try:

Blowing The Whistle.S08E15.mkv

The Sxx.Exx is reversed. I may not have described good enough, what I'm
looking for, but PLEASE, don't work on this any more. What you have given
me is all I can ask for and it works perfectly for the format I have, and
usually get.

For future reference ONLY, I'd like to have a script to change:

Blowing The Whistle.S08E15.mkv or

S08E15.Blowing The Whistle.mkv and

S08E15.HDTV.XviD-LOL.srt or
HDTV.XviD-LOL.S08E15.srt be

Blowing The Whistle.S08E15.srt or
S08E15.Blowing The Whistle.srt

I've tested Blowing The Whistle.S08E15.mkv, as I mentioned above... did
not work.

Maybe jrepl.bat can be tweaked to look for the "Sxx.Exx" ONLY, have YOUR
script set vids *.mkv and rename srt files.

I'm really script stupid, or I'd do it myself.

Again, thanks for all your work... you did goooooood. ;-)

Do you have a donation site?


















AlleyCat

unread,
Jan 20, 2016, 10:41:32 PM1/20/16
to

On Thu, 21 Jan 2016 14:21:48 +1100, foxidrive says...

> > On Wed, 20 Jan 2016 20:25:04 +1100, foxidrive says...

Works PERFECTLY!! Thanks!

AlleyCat

unread,
Jan 20, 2016, 10:42:33 PM1/20/16
to

On Thu, 21 Jan 2016 14:21:48 +1100, foxidrive says...

> > On Wed, 20 Jan 2016 20:25:04 +1100, foxidrive says...
>

Can this work recursively? Thanks.

AlleyCat

unread,
Jan 20, 2016, 10:43:14 PM1/20/16
to

On Wed, 20 Jan 2016 22:28:16 -0500, Todd Vargo says...
Thanks Todd. Can always count on you.

AlleyCat

unread,
Jan 20, 2016, 11:51:52 PM1/20/16
to

On Thu, 21 Jan 2016 14:21:48 +1100, foxidrive says...

> > It seems to be working except when I rename the vid file. I WILL come
> > across that... vid files named "xxxx.S01E01.mkv" or just S01E01.mkv
> >
> > Thanks for your help.
>
> No worries. The solution is even simpler.
>

Thanks again. I'm downloading subtitles to a (9 season - 196 episode) show
I have on the computer and so far so good.

:-)

foxidrive

unread,
Jan 21, 2016, 12:43:37 AM1/21/16
to
On 21/01/2016 15:51, AlleyCat wrote:
>
> On Thu, 21 Jan 2016 14:21:48 +1100, foxidrive says...
>
>>> Thanks for your help.
>>
>> No worries. The solution is even simpler.
>
> Thanks again. I'm downloading subtitles to a (9 season - 196 episode) show
> I have on the computer and so far so good.
>
> :-)

Jrepl is a great general purpose tool, but this can also be done in a
self-contained script.

The script below uses VBscript inside Windows Scripting Host and no longer
requires Jrepl.bat
- you've been very interested and provided good feedback, which makes the
task so much easier.

It works recursively, and in the same manner as the previous requirements
for the task.
Test it with various files: it's very likely that various filenames with
non-latin characters in them will simply fail to rename.

@echo off
:loop
set "file=%temp%\sarfile-%random%.vbs"
if exist "%file%" goto :loop

set out=regex.replace(wscript.stdin.readall,"$2|$1$2$3")
set "pattern=(.*\\.*)(S[0-9][0-9]E[0-9][0-9])(.*)"
set "global=true"
set "case=false"
>"%file%" echo(set regex=new regexp
>>"%file%" echo(regex.global=%global%
>>"%file%" echo(regEx.IgnoreCase=%case%
>>"%file%" echo(regex.pattern="%pattern%"
>>"%file%" echo(wscript.stdOut.write %out%
echo(Getting the list of video files
(for /f "delims=" %%a in ('
dir *.mkv *.avi *.mov *.mp4 *.mpg /b /a-d /s
') do echo %%a)>"%file%.2"
echo(Processing the list...
(for /f "tokens=1,* delims=|" %%a in ('
cscript /nologo "%file%" ^< "%file%.2"
') do if exist "%%~dpb*%%a*.srt" (
echo(@ren "%%~dpb*%%a*.srt" "%%~nb.srt"))>"+.bat.txt"
echo(done! - check "+.bat.txt" in this folder
del "%file%*"
pause


AlleyCat

unread,
Jan 21, 2016, 4:47:10 PM1/21/16
to

On Thu, 21 Jan 2016 16:43:32 +1100, foxidrive says...
Awesome! Thanks.

Now, if there was a way to rename ALL formats of srt files, i.e.,

MOST of the time, video files have the SxxExx format in the name, but
there are those who don't conform to convention, ergo, some use the
following formats:

201, 202, 203...

01x01, 01x02, 01x03...

Those would be OK, if the video files were included with the srt's in the
same folder, but I DO get a lot of vids without subtitles, so I have to
download them separately.

I DO have a series or two that have all three types of subtitle formats,
and it IS a pain to have to rename them, but those projects are long over.

Thanks for all of your help!!


















foxidrive

unread,
Jan 21, 2016, 8:21:48 PM1/21/16
to
On 22/01/2016 08:47, AlleyCat wrote:

> Now, if there was a way to rename ALL formats of srt files, i.e.,
>
> MOST of the time, video files have the SxxExx format in the name, but
> there are those who don't conform to convention, ergo, some use the
> following formats:
>
> 201, 202, 203...
>
> 01x01, 01x02, 01x03...
>
> Those would be OK, if the video files were included with the srt's in the
> same folder, but I DO get a lot of vids without subtitles, so I have to
> download them separately.
>
> I DO have a series or two that have all three types of subtitle formats,
> and it IS a pain to have to rename them, but those projects are long over.
>
> Thanks for all of your help!!


You know, that's quite doable.

The code below is functionally identical to the one just before - and
getting it to attempt the extra series/episode formats was trivial.


Extra formats can easily be added by duplicating the two lines that start
with the lines below
set "pattern="
"call :routine"

- the "format-01x03" on the call line only determines the filename of the
temporary batch scripts that do the actual renaming.
The "pattern" is a regular expression of the Windows variety, and is the
search term used to identify the right .SRT files for renaming.



Take note of the comments in the script - particularly in regard to the 103
series/episode format.



@echo off
: This creates temporary batch files to rename .SRT files
: to the same filename format as the video files.

: It is recursive in all folders below the current folder,
: and writes temporary batch files with a .txt extension
: into the current folder. eg: "+format-S01E03.bat.txt"

: - it attempts to use the series and episode number
: of the video file, and checks if an .SRT file with the
: same sequence of numbers exists in the same folder.

: If so then it writes a command to rename the .SRT file
: into the temporary batch file.

: *** Check the commands in the temporary batch file ***
: *** before manually running them, as undoing any ***
: *** mistaken renaming could be a headache. ***

: Simply using : at the front of a line will disable that command


: The format 103
: is the most likely to generate incorrect rename commands.



:loop
set "file=%temp%\sarfile-%random%.vbs"
if exist "%file%" goto :loop

set "pattern=(.*\\.*)(S[0-9][0-9]E[0-9][0-9])(.*)"
call :routine format-S01E03

set "pattern=(.*\\.*)([0-9][0-9]x[0-9][0-9])(.*)"
call :routine format-01X03

set "pattern=(.*\\.*)([0-9][0-9][0-9])(.*)"
call :routine format-103


echo(done! - check the "+*.bat.txt" files in "%cd%" folder
del "%file%*"
pause
goto :EOF


:routine
set out=regex.replace(wscript.stdin.readall,"$2|$1$2$3")
set "global=true"
set "case=false"

>"%file%" echo(set regex=new regexp
>>"%file%" echo(regex.global=%global%
>>"%file%" echo(regEx.IgnoreCase=%case%
>>"%file%" echo(regex.pattern="%pattern%"
>>"%file%" echo(wscript.stdOut.write %out%

echo(Getting the list of video files for %~1

(for /f "delims=" %%a in ('
dir *.mkv *.avi *.mov *.mp4 *.mpg /b /a-d /s
') do echo %%a)>"%file%.2"

echo(Processing the %~1 list...

(for /f "tokens=1,* delims=|" %%a in ('
cscript /nologo "%file%" ^< "%file%.2"
') do if exist "%%~dpb*%%a*.srt" (
echo(@ren "%%~dpb*%%a*.srt" "%%~nb.srt"))>"+%~1.bat.txt"
echo(@echo "%~1" renaming done>>"+%~1.bat.txt"
echo(

AlleyCat

unread,
Jan 22, 2016, 3:46:19 AM1/22/16
to

On Fri, 22 Jan 2016 12:21:46 +1100, foxidrive says...

> set "pattern=(.*\\.*)(S[0-9][0-9]E[0-9][0-9])(.*)"
> call :routine format-S01E03
>
> set "pattern=(.*\\.*)([0-9][0-9]x[0-9][0-9])(.*)"
> call :routine format-01X03
>
> set "pattern=(.*\\.*)([0-9][0-9][0-9])(.*)"
> call :routine format-103

[shrugging shoulders]

Keep in mind, my newsreader is not concatenating outside of 75±
characters. I hope I used that word right. ;-)

I'm not getting the part in the script, where it's all "103". Help?

Directory contents:
Burn Notice.207.srt
Burn Notice.208.srt
Burn Notice.S02E07.Rough Seas.avi
Burn Notice.S02E08.Double Booked.avi

Here's a twist... I DID have files where the srt file had the episode name
in it, but not the video file. What a super batch that would be, if it
could look for SxxExx in EITHER file, match that up with the various
formats; 207, 02x07 and S02E07 in either file and mirror them.

I'd buy THAT for a dollar.


What batch did:

N:\DVD's\Watched\Burn Notice\Season 2\Test>set "file=H:\Temp\sarfile-
16013.vbs"

N:\DVD's\Watched\Burn Notice\Season 2\Test>if exist "H:\Temp\sarfile-
16013.vbs" goto :loop

N:\DVD's\Watched\Burn Notice\Season 2\Test>set "pattern=(.*\\.*)(S[0-9][0-
9]E[0-9][0-9])(.*)"

N:\DVD's\Watched\Burn Notice\Season 2\Test>call :routine format-S01E03

N:\DVD's\Watched\Burn Notice\Season 2\Test>set out=regex.replace
(wscript.stdin.readall,"$2|$1$2$3")

N:\DVD's\Watched\Burn Notice\Season 2\Test>set "global=true"

N:\DVD's\Watched\Burn Notice\Season 2\Test>set "case=false"

N:\DVD's\Watched\Burn Notice\Season 2\Test>echo(set regex=new regexp 1>"H:
\Temp\sarfile-16013.vbs"

N:\DVD's\Watched\Burn Notice\Season 2\Test>echo(regex.global=true 1>>"H:
\Temp\sarfile-16013.vbs"

N:\DVD's\Watched\Burn Notice\Season 2\Test>echo(regEx.IgnoreCase=false
1>>"H:\Temp\sarfile-16013.vbs"

N:\DVD's\Watched\Burn Notice\Season 2\Test>echo(regex.pattern="(.*\\.*)(S
[0-9][0-9]E[0-9][0-9])(.*)" 1>>"H:\Temp\sarfile-16013.vbs"

N:\DVD's\Watched\Burn Notice\Season 2\Test>echo(wscript.stdOut.write
regex.replace(wscript.stdin.readall,"$2|$1$2$3") 1>>"H:\Temp\sarfile-
16013.vbs"

N:\DVD's\Watched\Burn Notice\Season 2\Test>echo(Getting the list of video
files for format-S01E03
Getting the list of video files for format-S01E03

N:\DVD's\Watched\Burn Notice\Season 2\Test>(for /F "delims=" %a in (' dir
*.mkv *.avi *.mov *.mp4 *.mpg /b /a-d /s ') do echo %a ) 1>"H:\Temp
\sarfile-16013.vbs.2"

N:\DVD's\Watched\Burn Notice\Season 2\Test>echo(Processing the format-
S01E03 list...
Processing the format-S01E03 list...

N:\DVD's\Watched\Burn Notice\Season 2\Test>(for /F "tokens=1,* delims=|" %
a in (' cscript /nologo "H:\Temp\sarfile-16013.vbs" < "H:\Temp\sarfile-
16013.vbs.2" ') do if exist "%~dpb*%a*.srt" (echo(@ren "%~dpb*%a*.srt" "%
~nb.srt" ) ) 1>"+format-S01E03.bat.txt"

N:\DVD's\Watched\Burn Notice\Season 2\Test>echo(@echo "format-S01E03"
renaming done 1>>"+format-S01E03.bat.txt"

N:\DVD's\Watched\Burn Notice\Season 2\Test>echo(


N:\DVD's\Watched\Burn Notice\Season 2\Test>set "pattern=(.*\\.*)([0-9][0-
9]x[0-9][0-9])(.*)"

N:\DVD's\Watched\Burn Notice\Season 2\Test>call :routine format-01X03

N:\DVD's\Watched\Burn Notice\Season 2\Test>set out=regex.replace
(wscript.stdin.readall,"$2|$1$2$3")

N:\DVD's\Watched\Burn Notice\Season 2\Test>set "global=true"

N:\DVD's\Watched\Burn Notice\Season 2\Test>set "case=false"

N:\DVD's\Watched\Burn Notice\Season 2\Test>echo(set regex=new regexp 1>"H:
\Temp\sarfile-16013.vbs"

N:\DVD's\Watched\Burn Notice\Season 2\Test>echo(regex.global=true 1>>"H:
\Temp\sarfile-16013.vbs"

N:\DVD's\Watched\Burn Notice\Season 2\Test>echo(regEx.IgnoreCase=false
1>>"H:\Temp\sarfile-16013.vbs"

N:\DVD's\Watched\Burn Notice\Season 2\Test>echo(regex.pattern="(.*\\.*)
([0-9][0-9]x[0-9][0-9])(.*)" 1>>"H:\Temp\sarfile-16013.vbs"

N:\DVD's\Watched\Burn Notice\Season 2\Test>echo(wscript.stdOut.write
regex.replace(wscript.stdin.readall,"$2|$1$2$3") 1>>"H:\Temp\sarfile-
16013.vbs"

N:\DVD's\Watched\Burn Notice\Season 2\Test>echo(Getting the list of video
files for format-01X03
Getting the list of video files for format-01X03

N:\DVD's\Watched\Burn Notice\Season 2\Test>(for /F "delims=" %a in (' dir
*.mkv *.avi *.mov *.mp4 *.mpg /b /a-d /s ') do echo %a ) 1>"H:\Temp
\sarfile-16013.vbs.2"

N:\DVD's\Watched\Burn Notice\Season 2\Test>echo(Processing the format-
01X03 list...
Processing the format-01X03 list...

N:\DVD's\Watched\Burn Notice\Season 2\Test>(for /F "tokens=1,* delims=|" %
a in (' cscript /nologo "H:\Temp\sarfile-16013.vbs" < "H:\Temp\sarfile-
16013.vbs.2" ') do if exist "%~dpb*%a*.srt" (echo(@ren "%~dpb*%a*.srt" "%
~nb.srt" ) ) 1>"+format-01X03.bat.txt"

N:\DVD's\Watched\Burn Notice\Season 2\Test>echo(@echo "format-01X03"
renaming done 1>>"+format-01X03.bat.txt"

N:\DVD's\Watched\Burn Notice\Season 2\Test>echo(


N:\DVD's\Watched\Burn Notice\Season 2\Test>set "pattern=(.*\\.*)([0-9][0-
9][0-9])(.*)"

N:\DVD's\Watched\Burn Notice\Season 2\Test>call :routine format-103

N:\DVD's\Watched\Burn Notice\Season 2\Test>set out=regex.replace
(wscript.stdin.readall,"$2|$1$2$3")

N:\DVD's\Watched\Burn Notice\Season 2\Test>set "global=true"

N:\DVD's\Watched\Burn Notice\Season 2\Test>set "case=false"

N:\DVD's\Watched\Burn Notice\Season 2\Test>echo(set regex=new regexp 1>"H:
\Temp\sarfile-16013.vbs"

N:\DVD's\Watched\Burn Notice\Season 2\Test>echo(regex.global=true 1>>"H:
\Temp\sarfile-16013.vbs"

N:\DVD's\Watched\Burn Notice\Season 2\Test>echo(regEx.IgnoreCase=false
1>>"H:\Temp\sarfile-16013.vbs"

N:\DVD's\Watched\Burn Notice\Season 2\Test>echo(regex.pattern="(.*\\.*)
([0-9][0-9][0-9])(.*)" 1>>"H:\Temp\sarfile-16013.vbs"

N:\DVD's\Watched\Burn Notice\Season 2\Test>echo(wscript.stdOut.write
regex.replace(wscript.stdin.readall,"$2|$1$2$3") 1>>"H:\Temp\sarfile-
16013.vbs"

N:\DVD's\Watched\Burn Notice\Season 2\Test>echo(Getting the list of video
files for format-103
Getting the list of video files for format-103

N:\DVD's\Watched\Burn Notice\Season 2\Test>(for /F "delims=" %a in (' dir
*.mkv *.avi *.mov *.mp4 *.mpg /b /a-d /s ') do echo %a ) 1>"H:\Temp
\sarfile-16013.vbs.2"

N:\DVD's\Watched\Burn Notice\Season 2\Test>echo(Processing the format-103
list...
Processing the format-103 list...

N:\DVD's\Watched\Burn Notice\Season 2\Test>(for /F "tokens=1,* delims=|" %
a in (' cscript /nologo "H:\Temp\sarfile-16013.vbs" < "H:\Temp\sarfile-
16013.vbs.2" ') do if exist "%~dpb*%a*.srt" (echo(@ren "%~dpb*%a*.srt" "%
~nb.srt" ) ) 1>"+format-103.bat.txt"

N:\DVD's\Watched\Burn Notice\Season 2\Test>echo(@echo "format-103"
renaming done 1>>"+format-103.bat.txt"

N:\DVD's\Watched\Burn Notice\Season 2\Test>echo(


N:\DVD's\Watched\Burn Notice\Season 2\Test>echo(done! - check the
"+*.bat.txt" files in "N:\DVD's\Watched\Burn Notice\Season 2\Test" folder
done! - check the "+*.bat.txt" files in "N:\DVD's\Watched\Burn Notice
\Season 2\Test" folder

N:\DVD's\Watched\Burn Notice\Season 2\Test>del "H:\Temp\sarfile-
16013.vbs*"

N:\DVD's\Watched\Burn Notice\Season 2\Test>goto :EOF

AlleyCat

unread,
Jan 22, 2016, 3:54:36 AM1/22/16
to

On Fri, 22 Jan 2016 12:21:46 +1100, foxidrive says...

> set "pattern=(.*\\.*)(S[0-9][0-9]E[0-9][0-9])(.*)"
> call :routine format-S01E03
>
> set "pattern=(.*\\.*)([0-9][0-9]x[0-9][0-9])(.*)"
> call :routine format-01X03
>
> set "pattern=(.*\\.*)([0-9][0-9][0-9])(.*)"
> call :routine format-103

Sorry... cleaned up a bit to read easier.

Directory contents:
Burn Notice.207.srt
Burn Notice.208.srt
Burn Notice.S02E07.Rough Seas.avi
Burn Notice.S02E08.Double Booked.avi


echo(Getting the list of video files for format-S01E03

Shouldn't that be *S??E??* or some derivation of?

I get lost after set. LOL


set "file=H:\Temp\sarfile-16013.vbs"

if exist "H:\Temp\sarfile-16013.vbs" goto :loop

set "pattern=(.*\\.*)(S[0-9][0-9]E[0-9][0-9])(.*)"

call :routine format-S01E03

set out=regex.replace(wscript.stdin.readall,"$2|$1$2$3")

set "global=true"

set "case=false"

echo(set regex=new regexp 1>"H:\Temp\sarfile-16013.vbs"

echo(regex.global=true 1>>"H:\Temp\sarfile-16013.vbs"

echo(regEx.IgnoreCase=false 1>>"H:\Temp\sarfile-16013.vbs"

echo(regex.pattern="(.*\\.*)(S[0-9][0-9]E[0-9][0-9])(.*)" 1>>"H:\Temp
\sarfile-16013.vbs"

echo(wscript.stdOut.write regex.replace(wscript.stdin.readall,"$2|$1$2$3")
1>>"H:\Temp\sarfile-16013.vbs"

echo(Getting the list of video files for format-S01E03
Getting the list of video files for format-S01E03

(for /F "delims=" %a in (' dir *.mkv *.avi *.mov *.mp4 *.mpg /b /a-d /s ')
do echo %a ) 1>"H:\Temp\sarfile-16013.vbs.2"

echo(Processing the format-S01E03 list...
Processing the format-S01E03 list...

(for /F "tokens=1,* delims=|" %a in (' cscript /nologo "H:\Temp\sarfile-
16013.vbs" < "H:\Temp\sarfile-16013.vbs.2" ') do if exist "%~dpb*%a*.srt"
(echo(@ren "%~dpb*%a*.srt" "%~nb.srt" ) ) 1>"+format-S01E03.bat.txt"

echo(@echo "format-S01E03" renaming done 1>>"+format-S01E03.bat.txt"

echo(


set "pattern=(.*\\.*)([0-9][0-9]x[0-9][0-9])(.*)"

call :routine format-01X03

set out=regex.replace(wscript.stdin.readall,"$2|$1$2$3")

set "global=true"

set "case=false"

echo(set regex=new regexp 1>"H:\Temp\sarfile-16013.vbs"

echo(regex.global=true 1>>"H:\Temp\sarfile-16013.vbs"

echo(regEx.IgnoreCase=false 1>>"H:\Temp\sarfile-16013.vbs"

echo(regex.pattern="(.*\\.*)([0-9][0-9]x[0-9][0-9])(.*)" 1>>"H:\Temp
\sarfile-16013.vbs"

echo(wscript.stdOut.write regex.replace(wscript.stdin.readall,"$2|$1$2$3")
1>>"H:\Temp\sarfile-16013.vbs"

echo(Getting the list of video files for format-01X03
Getting the list of video files for format-01X03

(for /F "delims=" %a in (' dir *.mkv *.avi *.mov *.mp4 *.mpg /b /a-d /s ')
do echo %a ) 1>"H:\Temp\sarfile-16013.vbs.2"

echo(Processing the format-01X03 list...
Processing the format-01X03 list...

(for /F "tokens=1,* delims=|" %a in (' cscript /nologo "H:\Temp\sarfile-
16013.vbs" < "H:\Temp\sarfile-16013.vbs.2" ') do if exist "%~dpb*%a*.srt"
(echo(@ren "%~dpb*%a*.srt" "%~nb.srt" ) ) 1>"+format-01X03.bat.txt"

echo(@echo "format-01X03" renaming done 1>>"+format-01X03.bat.txt"

echo(


set "pattern=(.*\\.*)([0-9][0-9][0-9])(.*)"

call :routine format-103

set out=regex.replace(wscript.stdin.readall,"$2|$1$2$3")

set "global=true"

set "case=false"

echo(set regex=new regexp 1>"H:\Temp\sarfile-16013.vbs"

echo(regex.global=true 1>>"H:\Temp\sarfile-16013.vbs"

echo(regEx.IgnoreCase=false 1>>"H:\Temp\sarfile-16013.vbs"

echo(regex.pattern="(.*\\.*)([0-9][0-9][0-9])(.*)" 1>>"H:\Temp\sarfile-
16013.vbs"

echo(wscript.stdOut.write regex.replace(wscript.stdin.readall,"$2|$1$2$3")
1>>"H:\Temp\sarfile-16013.vbs"

echo(Getting the list of video files for format-103
Getting the list of video files for format-103

(for /F "delims=" %a in (' dir *.mkv *.avi *.mov *.mp4 *.mpg /b /a-d /s ')
do echo %a ) 1>"H:\Temp\sarfile-16013.vbs.2"

echo(Processing the format-103 list...
Processing the format-103 list...

(for /F "tokens=1,* delims=|" %a in (' cscript /nologo "H:\Temp\sarfile-
16013.vbs" < "H:\Temp\sarfile-16013.vbs.2" ') do if exist "%~dpb*%a*.srt"
(echo(@ren "%~dpb*%a*.srt" "%~nb.srt" ) ) 1>"+format-103.bat.txt"

echo(@echo "format-103" renaming done 1>>"+format-103.bat.txt"

echo(


echo(done! - check the "+*.bat.txt" files in "N:\DVD's\Watched\Burn Notice
\Season 2\Test" folder
done! - check the "+*.bat.txt" files in "N:\DVD's\Watched\Burn Notice
\Season 2\Test" folder

del "H:\Temp\sarfile-16013.vbs*"

goto :EOF

foxidrive

unread,
Jan 22, 2016, 4:05:45 AM1/22/16
to
On 22/01/2016 19:54, AlleyCat wrote:
>
> On Fri, 22 Jan 2016 12:21:46 +1100, foxidrive says...
>
>> set "pattern=(.*\\.*)(S[0-9][0-9]E[0-9][0-9])(.*)"
>> call :routine format-S01E03
>>
>> set "pattern=(.*\\.*)([0-9][0-9]x[0-9][0-9])(.*)"
>> call :routine format-01X03
>>
>> set "pattern=(.*\\.*)([0-9][0-9][0-9])(.*)"
>> call :routine format-103
>
> Sorry... cleaned up a bit to read easier.
>
> Directory contents:
> Burn Notice.207.srt
> Burn Notice.208.srt
> Burn Notice.S02E07.Rough Seas.avi
> Burn Notice.S02E08.Double Booked.avi
>
>
> echo(Getting the list of video files for format-S01E03
>
> Shouldn't that be *S??E??* or some derivation of?

Without commenting on the example of a format string - what did the code do
to your files that is the problem?
Can you paste the rename commands in the files?

The cmd prompt output without echo off is unwieldy to browse through here,
without knowing what problem there may be. :)


The format string shown is just an example of the sort of string it will
look for.
EG: "103" is an example of the types you showed such as 203 204 205 206 etc
and also 103 108 403 703 etc.


The filenames you have shown match two type of file formats and neither of
the sets will match.


AlleyCat

unread,
Jan 22, 2016, 5:55:53 PM1/22/16
to

On Fri, 22 Jan 2016 20:05:42 +1100, foxidrive says...

> Without commenting on the example of a format string - what did the code
> do to your files that is the problem?

Nothing. No changes. All of the output bat files were to rename 103, 01x03
and S01E03. There were no files by those names.

> Can you paste the rename commands in the files?

+format-01X03.bat.txt
@echo "format-01X03" renaming done

+format-103.bat.txt
@echo "format-103" renaming done

+format-S01E03.bat.txt
@echo "format-S01E03" renaming done

Files in folder:
Burn Notice.207.srt
Burn Notice.208.srt
Burn Notice.S02E07.Rough Seas.avi
Burn Notice.S02E08.Double Booked.avi

> The cmd prompt output without echo off is unwieldy to browse through here,
> without knowing what problem there may be. :)

********************************************************************
Getting the list of video files for format-S01E03
Processing the format-S01E03 list...

Getting the list of video files for format-01X03
Processing the format-01X03 list...

Getting the list of video files for format-103
Processing the format-103 list...

done! - check the "+*.bat.txt" files in "N:\DVD's\Watched\Burn Notice
\Season 2\Test" folder

*********************************************************************

foxidrive

unread,
Jan 22, 2016, 10:43:28 PM1/22/16
to
On 23/01/2016 09:55, AlleyCat wrote:

> Files in folder:
> Burn Notice.207.srt
> Burn Notice.208.srt
> Burn Notice.S02E07.Rough Seas.avi
> Burn Notice.S02E08.Double Booked.avi

Thanks for the pastes and info AlleyCat.

The following line was meant to indicate that it only writes the rename
commands if the same series/episode format is inside the two files. I
didn't follow that your files can mix any of the three formats.

>> >The filenames you have shown match two type of file formats and neither of the sets will match.

It's easy to make it stop creating the files if no rename commands are inside.



>[shrugging shoulders]
>I'm not getting the part in the script, where it's all "103". Help?

Did I explain the 103 enough to understand? If I didn't, then ask for
clarification of the part you misunderstand.

Zaidy036

unread,
Jan 10, 2022, 5:42:27 PM1/10/22
to
On 1/17/2016 5:20 PM, AlleyCat wrote:
>
> Hello all. I think this will be simple for you batch and script gurus, but
> it's driving me crazy.
>
> Videofile: House.S08E18.Body And Soul.mkv
>
> Subtitle: House.S08E18.HDTV.XviD-LOL.srt
>
> If you please... copy text after third period (or whatever will be before
> the extension in other cases) of videofile and copy it to the srt file, so
> both files are identical other than the extension.
>
> Sample: House.S08E18.Body And Soul.mkv
> House.S08E18.Body And Soul.srt
>
> Not all vid files are in this "format", but I'll work on it from there.
>
> Thank you so very much.
>
Substitution works for you:

SET Title="House.S08E18.Body And Soul.mkv"
SET Title2="%Title:~0,-3%srt
then
Echo Title2
gives
House.S08E18.Body And Soul.srt

0 new messages