我在使用正在进行触摸校准的软件拍摄多台计算机时遇到了麻烦。该软件正在创建我需要复制和分析的.jpg
个文件,但是不同的用户已经将软件安装在不同的位置,这使得它可以搜索文件。文件示例为002CAL000211.jpg
。
我想创建一个可以执行以下操作的批处理文件:
使用(子文件夹)搜索整个C:
驱动器,并根据以下条件自动将特定文件复制到设置目录:
CAL
”.jpg
”我希望将文件复制到已安装的USB驱动器的根目录。
任何帮助都将受到高度赞赏!
谢谢!
答案 0 :(得分:0)
试试这个批处理脚本:
@echo off
type banner.txt
if [%1]==[] goto usage
:verify_argv
IF '%1'=='canon' GOTO get_canon_path
IF '%1'=='xerox' GOTO get_xerox_path
IF '%1'=='hp' GOTO get_hp_path
IF '%1'=='dell' GOTO get_dell_path
IF '%1'=='brother' GOTO get_brother_path
goto :eof
:get_canon_path
set dir_path=\\mgtutils01\windows7apps\PRINTERS\Canon
goto :install_drivers
:get_xerox_path
set dir_path=\\mgtutils01\windows7apps\PRINTERS\Xerox
goto :install_drivers
:get_hp_path
set dir_path=\\mgtutils01\windows7apps\PRINTERS\HP
goto :install_drivers
:get_dell_path
set dir_path=\\mgtutils01\windows7apps\PRINTERS\Dell
goto :install_drivers
:get_brother_path
set dir_path=\\mgtutils01\windows7apps\Brother\Drivers
goto :install_drivers
:usage
@echo Usage: .\driver [PRINTER_TYPE]
exit /B 1
:install_drivers
@echo Finding drivers...
pushd "%dir_path%"
forfiles /s /m *.exe /c "cmd /c echo @relpath"
set /p to_install="Copy the path of the correct driver and paste here: "
@echo Copying file to %USERPROFILE%, please wait..
xcopy %to_install% "%USERPROFILE%\Desktop"
@echo Installing driver..
pushd "%USERPROFILE%\Desktop"
编辑:16/03/2017 @ 20:00
@echo off
Title Searching for a specific file (name and type) and copy to USB Drive
Mode con cols=90 lines=10 & color 9E
setlocal ENABLEDELAYEDEXPANSION
for /f "tokens=2" %%i in ('wmic logicaldisk where "drivetype=2" ^|find /i ":"') do (Set MyUSB=%%i)
set _drive=%MyUSB%
If defined _drive (
cls
echo.
echo ---------------------------------------------------------
echo Your usb key is connected as !_drive!
echo ---------------------------------------------------------
echo.
pause
Goto :search
) ELSE (
cls
color 0C
echo.
echo --------------------------------------------------------------------------
echo Your usb key is not detected, please check it and re-run again this script
echo --------------------------------------------------------------------------
echo.
)
pause
exit
:Search
Cls
echo(
echo --------------------------------------------------------------------------
echo Please Wait a while ....... Searching is in progress .........
echo --------------------------------------------------------------------------
set "LogSearch=%~dp0%~n0.txt"
set Pattern="*CAL*.jpg"
Where /R C:\ "%Pattern%" /F >"%LogSearch%" 2>&1
If "%ErrorLevel%"=="1" (
Cls
echo(
echo --------------------------------------------------------------------------
@echo No file found with this Pattern
echo --------------------------------------------------------------------------
) else (
for /f "delims=" %%a in ('Type "%LogSearch%"') do (
@echo found %%a
@Copy %%a !_drive!\
)
)
pause & exit