一个文本有很多照片名(里面有重复的),一个文件夹有图片(无重复的, 用BAT找到文本相同名称的照片复制

2024-12-01 11:32:19
推荐回答(1个)
回答1:

@echo off

setlocal EnableDelayedExpansion

set /p "namea=请输入文本文件名称:"
if not exist %namea% (
echo “不存在文本文件名”
echo “请检查后再重试”
pause
exit
) else (
set /p "nameb=请输入放图片的文件夹名称:"
)
if not exist %nameb% (
echo “不存在此文件夹”
echo “请检查后重试”
pause
exit
) else (
set /p "namec=请输入要复制到的文件夹名称:"
)
if not exist %namec% (
echo “不存在此文件夹”
echo “请检查后重试”
pause
exit
) else (
for /f "tokens=3 delims= " %%a in ('find 7 /c "" %namea%') do (
set n=%%a
set /a a=!n!-1
for /l %%b in (1,1,!n!) do (
set Skip=skip=!a!
for /f "%Skip% delims=" %%c in (%namea%) do (
copy %cd%\%nameb%\%%c %cd%\%namec%
set /a a=!a!-1
))))
if everlevel==0 (
echo 成功
pause
exit
) exit (
echo 失败
pause
exit
)