本帖最后由 WHY 于 2024-7-2 00:25 编辑
- dir /b /a-d *.txt | sed -r "/[0-9]/!d; s/[^0-9]+//g"
复制代码
- dir /b /a-d *.txt | gawk "/[0-9]/{gsub(/[^0-9]+/, \"\");print}"
复制代码
- PowerShell "(dir *[0-9]*.txt -File).BaseName -replace '\D+'"
复制代码
- @if(0)==(0) echo off
- dir /b /a-d *.txt | cscript //nologo //e:jscript "%~f0"
- pause & exit
- @end
-
- while (!WSH.StdIn.AtEndOfStream) {
- var s = WSH.StdIn.Readline().replace(/\D+/g, '');
- if (/./.test(s)) WSH.Echo(s);
- }
复制代码 假设文件名不超过256个字符。事实上,在默认情况下,Windows系统中的路径长度被限制在256个字符以内。
0x!s:~15,1! 应该是16- @echo off
- for /L %%i in (0 1 9) do set _%%i=1
- for /f "delims=" %%i in ('dir /b /a-d *.txt ^| findstr "[0-9]"') do (
- set "name=%%~ni"
- setlocal enabledelayedexpansion
- set "s=!name!"
- for %%j in (128 64 32 16) do (
- if "!s:~%%j!" NEQ "" (
- set /a Len+=%%j
- set "s=!s:~%%j!"
- )
- )
- set "s=!s!FEDCBA9876543210"
- set /a Len+=0x!s:~16,1!
- for /L %%j in (0 1 !Len!) do (
- set "s1=!name:~%%j,1!"
- if defined _!s1! (
- set "newName=!newName!!s1!"
- )
- )
- echo;!newName!
- endlocal
- )
- pause
复制代码
|