Search code examples
windowsbatch-filecmdcommand-promptyoutube-dl

Why is "[youtube-dl -f "bestvideo[height<=1080]+bestaudio/best[height<=1080]" ytlink]" not working in a Windows batch file?


I made a batch file which contains:-

set /p ytlink="Enter the link of Youtube Video:-  "  
youtube-dl -f "bestvideo[height<=1080]+bestaudio/best[height<=1080]" ytlink  
pause

But the output i got is:-

ERROR: 'ytlink' is not a valid URL. Set --default-search "ytsearch" (or run  youtube-dl "ytsearch:ytlink" ) to search YouTube

My aim is to make a batch file in which i can enter youtube link which it will download.


Solution

  • You currently simply pass the text ytlink to youtube-dl. To pass the content of the ytlink variable, use %ytlink%.

    set /p ytlink="Enter the link of Youtube Video:-  "  
    youtube-dl -f "bestvideo[height<=1080]+bestaudio/best[height<=1080]" %ytlink%  
    pause