2015-11-04 167 views
1

我將多個批處理文件合併爲一個批處理文件。 我有幾個問題。 我正在瀏覽成千上萬的圖片,當我遇到需要將其複製到我的文檔以供日後查看時,這就是腳本中的「副本」。我已將其設置爲循環,以便可以繼續輸入文件以發送到我的文檔。 首先。當我輸入菜單時,我希望能夠跳回到菜單,所以它將離開循環並轉到:菜單。其次。我不知道這是否可能......但是經歷了很多照片,我希望能夠保存我離開的地方。那就是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 
+0

我想你會想要使用類似下面的內容:http://www.ericphelps.com/batch/samples/getini.txt – Leptonator

回答

0

我想出了另一種方式來退出循環,現在我只需要輸入任何不夾中匹配的名稱。 這就是我現在擁有的,並且工作得很好。

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