ZeronoFreya 当前离线
列兵
TOP
terse 当前离线
中将
(Get-ChildItem * -Recurse -include "*.txt") -Match "\[\d\d\]" | % {$_.MoveTo($_.DirectoryName + ($_.name -Replace '.*\[(\d{2})\].*','\$1.txt'))}复制代码
(Get-ChildItem * -Recurse -include "*.txt") -Match "\[\d\d\]" | foreach { move-item -LiteralPath $_ ($_.DirectoryName + ($_.Name -Replace '.*\[(\d\d)\].*','\$1.txt'))}复制代码
CrLf 当前离线
论坛巡查
@set @n=0;/* & echo off if "%~1" == "" echo,请拖拽文件夹&pause&exit if not exist "%~1\" echo,请拖拽文件夹&pause&exit pushd "%~1\" for /f "delims=" %%a in ('dir/b/s *.txt^|findstr "\[[0-9][0-9]\][^\\]*$"^|cscript -nologo -e:jscript %0')do ( Ren %%a 2>nul ) pause & exit/b */ var text = WScript.StdIn.ReadAll().replace(/\r|\n$/g,'') WScript.Echo(text.replace(/^(.*?[^\\]*\[(\d{2})\][^\\]*)$/gm, '"$1" "$2.txt"'))复制代码
(Get-ChildItem -Recurse *.txt) -Match "\[\d\d\]" | Rename-Item -NewName {$_.name -replace '.*\[(\d\d)\].*','$1.txt'}复制代码
@dir /s /a-d /b *.txt | gawk -F "\\" "{q=\"\x22\";if(match($NF,\"\\[[0-9]{2}\\]\",a))system(\"cmd /c ren\",q $NF q,q substr(a[0],2,2) \".txt\" q)}"复制代码
@dir /s /a-d /b *.txt | sed "s/.*\[\([0-9][0-9]\)\][^\\]*/ren \"^&\" \"\1.txt\"/;ta;d;:a" | cmd复制代码
apang 当前离线
上将
@set @n=0;/* & echo off if "%~1" == "" echo,请拖拽文件夹&pause&exit if not exist "%~1\" echo,请拖拽文件夹&pause&exit pushd "%~1\" for /f "delims=" %%a in ('dir/b/s *.txt^|cscript -nologo -e:jscript %0')do ( echo,Ren %%a 2>nul ) pause & exit/b & rem */ while (!WScript.StdIn.AtEndOfStream) { f = WScript.StdIn.ReadLine(); name = f.replace(/.*?\[(\d{2})][^\\]*$/, "$1"); if (f != name) { WScript.StdOut.WriteLine('"' + f + '" "' + name + '.txt"'); }; }复制代码
g495326 当前离线
一级士官
@echo off setlocal enabledelayedexpansion if "%~1" == "" ( set /p path=请输入需要修改的文件夹 if "!path:~2,1!" equ ":" ( set path=!path:~1,-1! ) ) else ( set path=%~1 ) set /p name=请输入需要修改的文件名,可以包含通配符: set /p order=请输入排序方式^(n:名称;e:扩展名;d:时间;s:大小;-:否定^): set /p main=设置需要修改成的文件名的公共部分: set /p num=请输入开始序列(直接回车默认为1) if not defined num ( set num=1 ) echo. for /f "delims=" %%i in ('dir /a-d /b /o%order% "%path%\%name%"') do ( if "%%i" neq "%~nx0" ( echo 正在处理: "%path%\%%i" ren "%path%\%%i" %main%!num!%%~xi set /a num+=1 ) ) echo. echo All Done echo Press any key to exit pause>nul复制代码
522235677 (张三)当前离线
少校
@echo off for /f "delims=" %%a in ('dir /b "%~1"') do ( for /f "tokens=1,2,3,4,5,6,7,8 delims=[]" %%b in ("%%~nxa") do ren "%~1\%%a" "%%b%%c%%d%%e%%f%%g%%h%%i%%~xa" ) pause复制代码
@echo off for /f "delims=" %%a in ('dir /b "%~1"') do ( for /f "tokens=2 delims=[]" %%b in ("%%~nxa") do echo ren "%~1\%%a" "%%b%%~xa" ) pause复制代码