qd2024 当前离线
三级士官
newswan 当前离线
上尉
TOP
wanghan519 当前离线
二级士官
#@&cls&powershell "type '%~0'|out-string|iex"&pause&exit dir *.pdf | group {$_.Name -replace '_.*$'} | %{$m=0;$_.Group | sort {$_.Name.Length} -Descending | %{$a=$_.Name -split '[_.]';if($a[-2].Length -gt $m){$m=$a[-2].Length};rni $_.Name ($_.Name -replace '_(\d+)\.',"_$($a[-2].PadLeft($m,'0')).")}}复制代码
qixiaobin0715 当前在线
大校
@echo off setlocal enabledelayedexpansion for %%i in (1 10 100 1000 10000) do if exist *_%%i.pdf set n=%%i set /a n*=10 for /f "tokens=1* delims=_" %%i in ('dir /b /a-d *_*.pdf') do ( set m=%%~nj set /a m+=n ren "%%i_%%j" "%%i_!m:~1!%%~xj" ) pause复制代码
评分人数
pd1 当前离线
五级士官
<# : @echo off powershell -NoProfile -ExecutionPolicy bypass "Get-Content -literal '%~f0' |Out-String|Invoke-Expression" pause #> $file=dir *.pdf $n=([string]$file.Length).Length $file|%{ren $_ ([regex]::Replace($_.name,'(?<=_)\d+',{param([string]$a) "{0:d${n}}" -f [int]$a}))}复制代码
<# : @echo off powershell -NoProfile -ExecutionPolicy bypass "Get-Content -literal '%~f0' |Out-String|Invoke-Expression" pause #> $file=dir *.pdf $max=($file|%{[int]$_.BaseName.split("_")[1]}|Measure-Object -Maximum).Maximum $n=([string]$max).Length $file|%{ren $_ ([regex]::Replace($_.name,'(?<=_)\d+',{param([string]$a) "{0:d${n}}" -f [int]$a}))}复制代码
ShowCode 当前离线
VIP1
@echo off cd /d "%~dp0" setlocal enabledelayedexpansion set "MaxLen=0" for /f "tokens=2 delims=_" %%a in ('dir /b /a-d *_*.pdf') do ( for /f "skip=1 delims=:" %%i in ('^(echo "%%a"^&echo.^)^|findstr /o ".*"') do ( set /a StrLen=%%i-5-4 ) if !StrLen! gtr !MaxLen! ( set "MaxLen=!StrLen!" ) ) set "MaxNum=1" for /l %%a in (1,1,!MaxLen!) do ( set /a MaxNum=MaxNum*10 ) for /f "tokens=1* delims=_" %%a in ('dir /b /a-d *_*.pdf') do ( set "FileNum=%%b" set "FileNum=!MaxNum!!FileNum:~0,-4!" ren "%%a_%%b" "%%a_!FileNum:~-3!%%~xb" )复制代码
aloha20200628 当前离线
@echo off &setlocal enabledelayedexpansion dir /b/s/a-d "%~1\*.pdf">0.0 & (call :getMax 0.0 m) (endlocal & set "max=%m%") & setlocal enabledelayedexpansion for /L %%n in (1,1,%max%) do set "p=0!p!" for /f "delims=" %%F in (0.0) do ( set "xF=%%~xF" for /f "tokens=1-2 delims=_" %%1 in ("%%~nF") do (set "q=!p!%%2" & ren "%%~F" "%%1_!q:~-%max%!!xF!") ) del 0.0 & endlocal & exit/b :getMax // %1=listF %2=digits :[loop] set/a "k+=1" & set "n=!n![0-9]" & findstr "!n!\.pdf" %1>nul && goto[loop] || (set/a "%~2=k-1" & exit/b)复制代码
:getMax // %1=listF %2=digits for /L %%n in (0,1,9) do set "n=!n![0-9]" & findstr "!n!\.pdf" %1>nul || (set/a "%~2=%%n" & exit/b)复制代码
buyiyang 当前离线
中尉
(echo "ABC"&echo.)|findstr /o ".*"复制代码
(echo,a)>1.txt复制代码
61 0D 0A复制代码
echo,a|find /v "">1.txt 61 0D 0A 复制代码
(echo,a)|find /v "">1.txt 61 20 0D 0A复制代码
(echo,a&echo,b)>1.txt 61 0D 0A 62 0D 0A复制代码
(echo,a&echo,b)|more>1.txt 61 20 0D 0A 62 20 0D 0A 0D 0A 复制代码
ppll2030 当前在线
四级士官
WHY 当前离线
上校
echo;a&echo;b pause复制代码