本帖最后由 pcl_test 于 2017-4-25 17:43 编辑
- @echo off&setlocal enabledelayedexpansion
- set "str1=GRANBLUE FANTASY"
- set "str2=[??]"
-
- set "str1_1=%str1%"
- set "str2_1=%str2%"
- for %%a in (.,$,^^^^,[,]) do (
- set "str1_1=!str1_1:%%a=\%%a!"
- set "str2_1=!str2_1:%%a=\%%a!"
- )
- set "str2_1=%str2_1:?=[0-9]%"
- set "t=%str2%fedcba987654321"&set /a n=0x!t:~15,1!
- for /l %%a in (0 1 %n%) do (
- if "!str2:~%%a,1!" equ "?" set _#%%a=%%a
- )
-
- for /f "delims=" %%a in ('dir /a-d/b *.mkv *.ass^|findstr /irc:".*%str1_1%.*%str2_1%"') do (
- call :rn "%%a"
- )
- pause&exit
- :rn
- set "fn=%~n1"
- set "fn=!fn:%str1%=!"
- set m=0
- :loop
- set "s="
- set "tmp=!fn:~%m%,%n%!"
- for /f "tokens=2 delims==" %%b in ('set _#') do set "s=!s!!tmp:~%%b,1!"
- for /f "tokens=1* delims=9876543210" %%c in ("#!s!") do (
- if "%%c%%d" equ "#" (
- for /l %%e in (0 1 9) do set "tmp=!tmp:%%e=!"
- if "!tmp!" equ "%str2:?=%" (
- echo;ren "%~1" "%str1%_!s!%~x1"
- goto :eof
- )
- )
- )
- set /a m+=1
- if "!tmp!" neq "" goto loop
复制代码
|