1) 此代码将尝试在 C:\Program Files (x86)\Arduino\libraries 中查找您的文件,如果找到,它将搜索下一个文件
@echo off && setlocal EnableDelayedExpansion
title <nul && title .\%~nx0
cd/d "%systemdrive%" && cd\
set "_output_dir=G:\SUPER_USER\Q60142344"
set "_input_file=G:\SUPER_USER\Q60142344\Q60142344.txt"
for %%s in (findstr,find,where
)do set "_%%~s=%%~s" && call set "_%%~s=%__APPDIR__%!_%%~s!.exe"
cd /d "C:\Program Files (x86)\Arduino\libraries"
for /f "tokens=2 delims=<>" %%i in ('type "!_input_file!"^|!_findstr! "< >"
')do for /f "tokens=* delims= " %%# in ('2^>nul !_where! /r . "%%~i"^|!_find! /i "%%~i"
')do if not "%%~#"=="!_output_dir!\%%i" >nul copy /y /v "%%~#" "!_output_dir!" && echo/File "%%~#" Copied to "!_output_dir!"))
endlocal && goto :EOF
File "C:\Program Files (x86)\Arduino\libraries\SD.h" Copied to "G:\SO_en\Q60142344"))
File "C:\Program Files (x86)\Arduino\libraries\SPI.h" Copied to "G:\SO_en\Q60142344"))
File "C:\Program Files (x86)\Arduino\libraries\HCSR04.h" Copied to "G:\SO_en\Q60142344"))
- 只需在上述变量中添加相关值即可进行编辑,以匹配必要的操作
set "_output_dir=G:\SO_en\Q60142344" && set "_input_file=G:\SO_en\Q60142344\Q60142344.txt"
set "_output_dir=A:\the\path\to\folder\target" && set "_input_file=B:\the\path\to\file\input_file.h"
2) 此代码将尝试在 C: 中查找您的文件,如果找到,它将搜索下一个文件
另外,它会避免在目标文件夹中查找,如果它存在于目标文件夹中,它也会忽略。
- 只需在上述变量中添加相关值即可进行编辑,以匹配必要的操作
set "_output_dir=G:\SO_en\Q60142344" && set "_input_file=G:\SO_en\Q60142344\Q60142344.txt"
set "_output_dir=A:\the\path\to\folder\target" && set "_input_file=B:\the\path\to\file\input_file.h"
@echo off && setlocal EnableDelayedExpansion
title <nul && title .\%~nx0
cd/d "%systemdrive%" && cd\
set "_output_dir=G:\SO_en\Q60142344"
set "_input_file=G:\SO_en\Q60142344\Q60142344.txt"
for %%s in (findstr,find,where
)do set "_%%~s=%%~s" && call set "_%%~s=%__APPDIR__%!_%%~s!.exe"
for /f "tokens=2 delims=<>" %%i in ('type "!_input_file!"^|!_findstr! "< >"
')do if not exist "!_output_dir!\%%~i" (for /f "tokens=* delims= " %%# in ('
2^>nul !_where! /r %systemdrive%\ "%%~i"^|!_find! /i "%%~i"')do if not "%%~#"=="!_output_dir!\%%i" (
>nul copy /v "%%~#" "!_output_dir!" && cd/d "%~dp0" && echo/File "%%~#" Copied to "!_output_dir!" ))
endlocal && goto :EOF
File "C:\Users\ecker\AppData\Local\Temp\SD.h" Copied to "G:\SO_en\Q60142344"
File "C:\Users\ecker\Downloads\SPI.h" Copied to "G:\SO_en\Q60142344"
File "C:\Users\ecker\Downloads\HCSR04.h" Copied to "G:\SO_en\Q60142344"
3) 此代码将尝试在计算机上的所有驱动器上查找您的文件,如果在驱动器上找到,它将搜索下一个文件,而不检查剩余驱动器已找到相同的文件。
另外,它会避免在目标文件夹中查找,如果它存在于目标文件夹中,它也会忽略。
- 只需在上述变量中添加相关值即可进行编辑,以匹配必要的操作
set "_output_dir=A:\the\path\to\folder\target"
set "_input_file=B:\the\path\to\file\input_file.h"
@echo off && setlocal EnableDelayedExpansion
title <nul && title .\%~nx0
set "_output_dir=G:\SO_en\Q60142344"
set "_input_file=G:\SO_en\Q60142344\Q60142344.h"
set "_wmic=%__APPDIR__%wbem\wmic.exe logicaldisk get caption"
for %%s in (findstr,find,where)do set "_%%~s=%%~s" && call set "_%%~s=%__APPDIR__%!_%%~s!.exe"
for /f "tokens=2 delims=<>" %%i in ('type "!_input_file!"^|!_findstr! "< >"
')do for /f "tokens=1" %%D in ('!_wmic! ^|!_find! ":"')do cd /d "%%~D\" && cd\ & if not exist "!_output_dir!\%%~i" (
echo/Looking for file %%i in %%~D\... & for /f "tokens=*delims= " %%# in ('2^>nul !_where! /r \ "%%~i"^|!_find! /i "%%i"
')do if not "%%~#"=="!_output_dir!\%%i" >nul copy /y "%%~#" "!_output_dir!" && cd/d "%~dp0" && echo/File "%%~#" Copied to "!_output_dir!")
endlocal && goto :EOF
Looking for file SD.h in C:\...
File "C:\Users\ecker\AppData\Local\Temp\SD.h" Copied to "G:\SO_en\Q60142344"
Looking for file SPI.h in C:\...
File "C:\Users\ecker\Downloads\SPI.h" Copied to "G:\SO_en\Q60142344"
Looking for file TMRpcm.h in C:\...
Looking for file TMRpcm.h in G:\...
File "G:\TMRpcm.h" Copied to "G:\SO_en\Q60142344"
Looking for file HCSR04.h in C:\...
File "C:\Users\ecker\Downloads\HCSR04.h" Copied to "G:\SO_en\Q60142344"
Obs.: 要复制到以下文件夹之一,请了解必须以管理员身份运行批处理::
%ProgramFiles% == C:\Program Files (x86)
%ProgramFiles(x86)% == C:\Program Files (x86)
%ProgramW6432% == C:\Program Files