我正在以更简单的方式安装我们的ROV控制软件。我管理了几乎所有我想做的事情,但我们有40个系统,每个系统都有唯一的输入文件夹,必须在C:\Innovator\Input
。
每个系统都有一个唯一的Input
文件夹,其中包含该控制系统的所有相关文件和变量。
我找到了一个很好的脚本,允许用户定义他们想要复制到文件夹C:\Innovator
的输入文件夹。但我不知道如何使脚本将指定的INN_01
到INN_41
文件夹复制到文件夹C:\Innovator
,见下文。
提前感谢您提供的任何帮助。
echo.
echo.
echo ===========================================================
echo Starting on !date! !time! on !Computername!
echo ===========================================================
echo.
goto :main
:main
setlocal
set /P innovator=Please type the ID of the system you would like to restore (ie, INN_03):
set innovatorDir=D:\files\Innovator\Systems_inputs\!innovator!\
set app=setup.exe /cd
set log=c:\logs.txt
echo. Starting on !date! !time! on !Computername! >> !log!
echo.
echo The input folder you selected is for: !innovator!
echo.
goto :user
:user
set /p answer=Is this correct (Y/N)?
echo.
if /i !answer!==y goto :yes (
) else (
echo.
echo Ok. Let's try again and this time get it right ya MONG^^!
echo.
Pause
cls
goto :beginning
)
)
:yes
for /d %%i in ( !innovatordir!*media1\setup ) do (
start !app!
)
endlocal
goto :eof
答案 0 :(得分:0)
这是我认为你想要的批处理文件。以rem
开头的行是注释行。
@echo off
echo.
echo.
echo ===========================================================
echo Starting on %DATE% %TIME% on %COMPUTERNAME%
echo ===========================================================
echo.
setlocal EnableDelayedExpansion
:UserChoice
set InnovatorID=00
set /P "FolderID=Please type ID (01..41) of input folder, e.g. 03: "
rem Append a leading zero if just a single character (digit) was entered by user.
if "%FolderID:~-1%"=="%FolderID%" set "FolderID=0%FolderID%"
set "FolderName=C:\Innovator\Input\INN_%FolderID%"
echo.
rem Verify the existence of directory selected by ID.
if not exist "%FolderName%" (
echo "%FolderID%" is not a valid ID. Valid is 01 ... 41.
echo.
set Answer=y
set /P "Answer=Retry [y/n]: "
if /I "!Answer!"=="y" (
echo.
echo.
goto UserChoice
)
rem User decided to abort and therefore exit batch task.
endlocal
goto :EOF
)
rem Ask user for confirmation before processing. The default answer
rem is "y" (yes) and therefore user needs to press only RETURN/ENTER.
set Answer=y
set /P "Answer=Is ID %FolderID% correct [y/n]? "
if /I "%Answer%"=="y" goto Processing
echo.
echo OK, let's try again and this time get it right^^!
echo.
echo.
goto UserChoice
:Processing
set "log=%TEMP%\InputFolderCopy.log"
echo INN_%FolderID% copied on %DATE% %TIME% on %COMPUTERNAME%.1>>"%log%"
echo.
echo The input folder you selected is: INN_%FolderID%
echo.
xcopy "%FolderName%" "C:\Innovator" /E /H /I /K /Q /R /Y 1>nul
echo Processing finished.
echo.
endlocal
使用set "log=..."
修改该行以定义日志文件的名称和存储位置,该位置使用单行记录每个复制过程。日志文件应该很可能存储在公共服务器共享上,而不是存储在临时文件的本地目录中。