首页 > 编程 > BAT > 正文

全盘搜索指定文件并拷贝到指定位置[自动重命名]的批处理

2020-06-09 13:47:52
字体:
来源:转载
供稿:网友
代码如下:
@echo off&setlocal enabledelayedexpansion
set num=0
set /p filename=请输入要查找的文件名[包含文件扩展名]:
set /p newpath=请输入所要拷贝到的指定目录:
if not exist !newpath! md !newpath! 1>nul 2>nul
set zh=!newpath:~-1!
if !zh! NEQ "/" set newpath=!newpath!/
for %%a in (c d e f g h i j k l) do (
cd /d %%a:/
for /r . %%i in (*.exe) do (
if "%%~ni%%~xi"=="!filename!" set /a num=!num!+1 && copy "%%i" !newpath!%%~ni!num!%%~xi 1>nul 2>nul && echo %%i → %%~ni!num!%%~xi>>!newpath!filecopy.txt
)
)
start !newpath!filecopy.txt
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表