几个自动查找并复制文件的批处理代码

发布时间:2020-03-17编辑:脚本学堂
为大家提供几个可以自动查找并复制文件的批处理脚本,有需要的朋友可以参考下。

代码1:
 

复制代码 代码示例:
@echo off
for %%a in (c d e f g h i j k l m n o p q r s t u v w x y z)do (
for /f "delims=" %%b in ('dir /a/b/s "%%a:GeosetManager50.exe"')do (
copy mapx50.lic "%%~dpb" /y
))
pause

代码2:
 

复制代码 代码示例:
@echo off
rem 系统要求WinXP以上
SetLocal EnableDelayedExpansion
for /f "delims=" %%i in ('fsutil fsinfo drives^|find /v ""') do (
set "var=%%i"
set "drive=!var:~-2!"
fsutil fsinfo drivetype !drive!|find "固定">nul &&call :slz "!drive!"
)
echo 任务已完成&pause

代码3:
 

复制代码 代码示例:
:slz
if "%~1"=="" goto:eof
for /f "delims=" %%a in ('dir/s/b/a-d "%~1GeosetManager50.exe" ^>nul 2^>nul') do (
set "var2=%%~dpa"
if defined var2 xcopy /y/h/r mapx50.lic "%var%"
)
set "var2="
goto:eof

代码4:
 

复制代码 代码示例:
SetLocal EnableDelayedExpansion
for /f "delims=" %%i in ('fsutil fsinfo drives^|find /v ""') do (
set var=%%i
set drive=!var:~-2!
fsutil fsinfo drivetype !drive!|find "固定">nul & for /f "delims=" %%a in ('dir/s/a-d/b !drive!GeosetManager50.exe 2^>nul') do copy "mapx50.lic" "%%~dpa" /b /y
) & pause