批处理文件需要信息
问题描述:
我将多个批处理文件合并为一个批处理文件。 我有几个问题。 我正在浏览成千上万的图片,当我遇到需要将其复制到我的文档以供日后查看时,这就是脚本中的“副本”。我已将其设置为循环,以便可以继续输入文件以发送到我的文档。 首先。当我输入菜单时,我希望能够跳回到菜单,所以它将离开循环并转到:菜单。其次。我不知道这是否可能......但是经历了很多照片,我希望能够保存我离开的地方。那就是GOTO:Set来玩的地方。我希望能够输入图片的编号并将批量文件保存起来,这样当我输入GOTO:OPEN时,它将打开我从此开始的图片。批处理文件需要信息
对不起,如果这听起来令人困惑,任何帮助将是伟大的。如果您有任何问题随时问 谢谢
ECHO OFF
CLS
:MENU
CLS
ECHO.
ECHO ...............................................
ECHO Welcome to the sub-menu
ECHO ...............................................
ECHO.
ECHO 1 - Rename files in folder.
ECHO 2 - Copy files to My Documents.
ECHO 3 - Set file to you left off on.
ECHO 4 - Open file you left off on.
ECHO 5 - Exit.
ECHO.
SET /P M=Type 1, 2, 3, or 4 then press ENTER:
IF %M%==1 GOTO Rename
IF %M%==2 GOTO COPY
IF %M%==3 GOTO SET
IF %M%==4 GOTO OPEN
:Rename
setlocal EnableDelayedExpansion
set i=0
for %%a in (*.jpg) do (
set /a i+=1
ren "%%a" "!i!.new"
)
ren *.new *.jpg
GOTO MENU
:COPY
cls
SET /P filename=Enter the file which should be moved:
xcopy %filename%.* C:\Users\USERNAME\Documents
if not exist %filename%.* goto :Failure
if exist %filename%.* goto :data
GOTO MENU
:SET
GOTO MENU
:OPEN
GOTO Me
:Failure
echo Failure
pause
goto :COPY
:data
timeout /t 3
goto :COPY
答
我想出了另一种方式来退出循环,现在我只需要输入任何不夹中匹配的名称。 这就是我现在拥有的,并且工作得很好。
ECHO OFF
CLS
:MENU
CLS
ECHO.
ECHO ...............................................
ECHO Welcome to the sub-menu
ECHO ...............................................
ECHO.
ECHO 1 - Rename files in folder.
ECHO 2 - Copy files to My Documents.
ECHO 3 - Set file to you left off on.
ECHO 4 - Open file you left off on.
ECHO 5 - Exit.
ECHO.
SET /P M=Type 1, 2, 3, or 4 then press ENTER:
IF %M%==1 GOTO Rename
IF %M%==2 GOTO COPY
IF %M%==3 GOTO SET
IF %M%==4 GOTO OPEN
:Rename
setlocal EnableDelayedExpansion
set /p i=Enter Starting Number:
for %%a in (*.JPG) do (
set /a i+=1
ren "%%a" "!i!.new"
)
ren *.new *.JPG
GOTO MENU
:COPY
cls
SET /P filename=Enter the file which should be moved:
xcopy %filename%.* C:\Users\USERNAME\Documents
if not exist %filename%.* goto :Failure
if exist %filename%.* goto :data
:Failure
goto :menu
:data
timeout /t 3
goto :copy
GOTO MENU
:SET
cls
del temp.txt
set INPUT=
set /P INPUT=Type input: %=%
echo Your input was: %INPUT%
pause
echo %INPUT%.JPG >>temp.txt
GOTO MENU
:OPEN
set /p texte=< temp.txt
echo %texte%
pause
set q=%texte%
start %texte%
GOTO menu
:Failure
echo Failure
pause
goto :COPY
:data
timeout /t 3
goto :COPY
我想你会想要使用类似下面的内容:http://www.ericphelps.com/batch/samples/getini.txt – Leptonator