本帖最后由 flashercs 于 2022-5-7 14:13 编辑
回复 8# duoduo200 - @echo off
- if not exist "%~dp1" exit /b
- cd /d "%~dp1" 2>nul
- for %%A in ("%~f1\..") do (
- set zhuanji=%%~nxA
- for %%B in ("%%~fA\..") do (
- set geshou=%%~nxB
- )
- )
- echo."%geshou%"|findstr /ric:"^\"[a-z]\"$" >nul && ( set "geshou=%zhuanji%" & set "zhuanji=")
- @REM echo zhuanji="%zhuanji%"
- @REM echo geshou="%geshou%"
- @REM 重命名音频
- @REM for %%G in ("%geshou%") do (
- @REM for %%Z in ("%zhuanji%") do (
- @REM )
- @REM )
- for /f "tokens=1-2 delims=|" %%A in ('dir /a-d /b *.wav *.flac *.dts *.dff *.mp3^|2^>nul powershell -c "begin{$ctr=0;$g=$env:geshou;$z=$env:zhuanji}process{$s=$($input);$bn=[system.io.path]::GetFileNameWithoutExtension($s);if($bn -eq $g -or $bn -eq $z){return}$s+'|'+(++$ctr).ToString().PadLeft(3,'0')+\".$g-\"+($s -replace ('^(\d+\.)?('+[regex]::Escape(\"$g\")+'\s*-\s*)*'),'')}"') do (
- ren "%%A" "%%B"
- )
- @REM 重命名文本图片
- for /d %%A in (.\*) do (
- pushd "%%A\"
- for /f "delims=" %%B in ('dir /a-d /b *.txt *.pdf *.doc *.ppt *.jpg *.jpeg *.png *.gif') do (
- if defined zhuanji (
- call :myren "%%~nxB" "%geshou%" "%zhuanji%"
- ) else (
- call :myren "%%~nxB" "%geshou%"
- )
- )
- popd
- )
-
- pause
- exit /b
-
- :myren srcname geshou zhuanji
- setlocal
- @REM 忽略文件名basename与歌手或专辑目录名相同的文件
- if /i "%~n1"=="%~2" goto end
- if /i "%~n1"=="%~3" goto end
- if "%~3"=="" (
- set "basename=%~2"
- ) else (
- set "basename=%~2-%~3"
- )
- set "newname=%basename%%~x1"
- set n=1000
- :loop
- if /i "%newname%"=="%~1" goto end
- if not exist "%newname%" (
- ren "%~1" "%newname%"
- goto end
- )
- set /a n+=1
- set "newname=%basename%_%n:~-3%%~x1"
- goto loop
- :end
- endlocal
- exit /b
复制代码
|