Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @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%
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement