试试这样- @echo off & cd /d "%~dp0"
- for /f "delims=" %%a in (需要找的.txt) do (
- set "n=1"
- if exist "E:\目标文件夹\%%a.docx" call :check "%%a"
- )
- pause&exit
-
- :check
- if not exist "E:\复制到的新文件夹\%~1.docx" (
- copy "E:\目标文件夹\%~1.docx" "E:\复制到的新文件夹\%~1.docx"
- ) else (
- if exist "E:\复制到的新文件夹\%~1_%n%.docx" (
- set /a "n+=1"
- goto :check
- ) else (
- copy "E:\目标文件夹\%~1.docx" "E:\复制到的新文件夹\%~1_%n%.docx"
- )
- )
- goto :eof
复制代码
|