2017-01-11 21 views
0

我想讓這個腳本跳轉到腳本的另一部分,如果沒有來自用戶的輸入。批處理腳本移動到腳本的另一部分,如果沒有來自用戶的輸入

倒在if%input%==區域。

我想要做的是跳到腳本檢查.mp4文件的部分,如果它們在那裏,就移動它們。我應該爲該部分設置一個變量或循環嗎?感謝您的任何答覆

@echo off 
echo Checking for youtube-dl updates. 

pause 
youtube-dl -U 
rem Enter the url or urls that you want to download from 

set /p input="Enter the url(s) you want to download:" 

rem Uses the youtube-dl continue (-c) option to download multiple files if not in a playlist 

youtube-dl -c "%input%" 



rem pause 

if %input%=="" GOTO:EOF 

cls 

echo Download complete, please wait while files are transfered to appropiate folder 

pause 

for %%o in (.mp4) do move "*%%o" "E:\Documents\scripts\videos\" 
if not exist do echo .mp4 files are no longer in this directory 
pause 

回答

0

下面的腳本怎麼樣?此腳本等待3秒,而「file.mp4」不存在。它一直等到文件存在。關於「文件名」,你可以改變你的腳本。

@echo off 
set waittime=3 
set filename=file.mp4 
:loop 
if not exist %filename% (
    Timeout /t %waittime% /nobreak > nul 
    goto loop 
) 
echo Find %filename% 
0

在做字符串比較批次,你必須確保,這兩個部分是平等的,而你的情況是不會發生的!在大多數語言中,字符串都有雙引號。批量他們通常不會。
要解決您的問題,請將雙引號中的%input%也括起來。
請注意,執行諸如"x%input%"=="x"之類的操作可能會很有用,以防止某些字符(如<>|)位於比較字符串的開頭。

你可以用這幾行檢查這個你自己:

@echo off 
set /p input="Input something or nothing here " 
echo %input% 
echo "%input%" 
pause 

如果你打沒有任何輸入回報,你會看到只有底部有一個將輸出""這是您比較字符串。

相關問題