本帖最后由 dos大帝 于 2021-11-8 16:41 编辑
- @echo off & setLocal enableDelayedExpansion
-
- for %%i in ("D:\A" "D:\B") do (
- pushd %%i
- for /f "delims=" %%j in ('dir /b *.txt 2^>nul ^| findstr /b "[0-9]"') do if "%%~xj" == ".txt" call :number %%j
- popd
- )
-
- goto ending
-
- :number
- set name=%~n1
- for /l %%j in (0,1,256) do (
- set sub_s=!name:~%%j,1!
- echo !sub_s!|findstr "[^0-9]" >nul && (
- set prefix=!name:~0,%%j!
- if defined _!prefix! (copy "%1" "D:\C\") else set "_!prefix!=1"
- goto :eof
- )
- )
- goto :eof
-
- :ending
- pause
复制代码 对比多个文件夹下txt文件名字, 数字开头且数字一致的文件将被复制到另一个文件夹, 在一个文件夹下发现相同的也复制 |