Automatically close Terminal window upon successful download? #8350

Closed
opened 2026-02-21 04:20:40 -05:00 by deekerman · 11 comments
Owner

Originally created by @kwolk on GitHub (Aug 3, 2016).

Please follow the guide below

  • You will be asked some questions and requested to provide some information, please read them carefully and answer honestly
  • Put an x into all the boxes [ ] relevant to your issue (like that [x])
  • Use Preview tab to see how your issue will actually look like

Make sure you are using the latest version: run youtube-dl --version and ensure your version is 2016.08.01. If it's not read this FAQ entry and update. Issues with outdated version will be rejected.

  • I've verified and I assure that I'm running youtube-dl 2016.08.01

Before submitting an issue make sure you have:

  • At least skimmed through README and most notably FAQ and BUGS sections
  • Searched the bugtracker for similar issues including closed ones

What is the purpose of your issue?

  • Bug report (encountered problems with youtube-dl)
  • Site support request (request for adding support for a new site)
  • Feature request (request for a new functionality)
  • Question
  • Other

The following sections concretize particular purposed issues, you can erase any section (the contents between triple ---) not applicable to your issue


If the purpose of this issue is a bug report, site support request or you are not completely sure provide the full verbose output as follows:

Add -v flag to your command line you run youtube-dl with, copy the whole output and insert it here. It should look similar to one below (replace it with your log inserted between triple ```):

$ youtube-dl -v <your command line>
[debug] System config: []
[debug] User config: []
[debug] Command-line args: [u'-v', u'http://www.youtube.com/watch?v=BaW_jenozKcj']
[debug] Encodings: locale cp1251, fs mbcs, out cp866, pref cp1251
[debug] youtube-dl version 2016.08.01
[debug] Python version 2.7.11 - Windows-2003Server-5.2.3790-SP2
[debug] exe versions: ffmpeg N-75573-g1d0487f, ffprobe N-75573-g1d0487f, rtmpdump 2.4
[debug] Proxy map: {}
...
<end of log>

If the purpose of this issue is a site support request please provide all kinds of example URLs support for which should be included (replace following example URLs by yours):


Description of your issue, suggested solution and other information

Explanation of your issue in arbitrary form goes here. Please make sure the description is worded well enough to be understood. Provide as much context and examples as possible.
If work on your issue required an account credentials please provide them or explain how one can obtain them.

I would like to know if it it possible to have Terminal automatically close the Window in use after it has successfully downloaded a batch file please?

Originally created by @kwolk on GitHub (Aug 3, 2016). ## Please follow the guide below - You will be asked some questions and requested to provide some information, please read them **carefully** and answer honestly - Put an `x` into all the boxes [ ] relevant to your _issue_ (like that [x]) - Use _Preview_ tab to see how your issue will actually look like --- ### Make sure you are using the _latest_ version: run `youtube-dl --version` and ensure your version is _2016.08.01_. If it's not read [this FAQ entry](https://github.com/rg3/youtube-dl/blob/master/README.md#how-do-i-update-youtube-dl) and update. Issues with outdated version will be rejected. - [x] I've **verified** and **I assure** that I'm running youtube-dl **2016.08.01** ### Before submitting an _issue_ make sure you have: - [x] At least skimmed through [README](https://github.com/rg3/youtube-dl/blob/master/README.md) and **most notably** [FAQ](https://github.com/rg3/youtube-dl#faq) and [BUGS](https://github.com/rg3/youtube-dl#bugs) sections - [x] [Searched](https://github.com/rg3/youtube-dl/search?type=Issues) the bugtracker for similar issues including closed ones ### What is the purpose of your _issue_? - [ ] Bug report (encountered problems with youtube-dl) - [ ] Site support request (request for adding support for a new site) - [ ] Feature request (request for a new functionality) - [x] Question - [ ] Other --- ### The following sections concretize particular purposed issues, you can erase any section (the contents between triple ---) not applicable to your _issue_ --- ### If the purpose of this _issue_ is a _bug report_, _site support request_ or you are not completely sure provide the full verbose output as follows: Add `-v` flag to **your command line** you run youtube-dl with, copy the **whole** output and insert it here. It should look similar to one below (replace it with **your** log inserted between triple ```): ``` $ youtube-dl -v <your command line> [debug] System config: [] [debug] User config: [] [debug] Command-line args: [u'-v', u'http://www.youtube.com/watch?v=BaW_jenozKcj'] [debug] Encodings: locale cp1251, fs mbcs, out cp866, pref cp1251 [debug] youtube-dl version 2016.08.01 [debug] Python version 2.7.11 - Windows-2003Server-5.2.3790-SP2 [debug] exe versions: ffmpeg N-75573-g1d0487f, ffprobe N-75573-g1d0487f, rtmpdump 2.4 [debug] Proxy map: {} ... <end of log> ``` --- ### If the purpose of this _issue_ is a _site support request_ please provide all kinds of example URLs support for which should be included (replace following example URLs by **yours**): - Single video: https://www.youtube.com/watch?v=BaW_jenozKc - Single video: https://youtu.be/BaW_jenozKc - Playlist: https://www.youtube.com/playlist?list=PL4lCao7KL_QFVb7Iudeipvc2BCavECqzc --- ### Description of your _issue_, suggested solution and other information Explanation of your _issue_ in arbitrary form goes here. Please make sure the [description is worded well enough to be understood](https://github.com/rg3/youtube-dl#is-the-description-of-the-issue-itself-sufficient). Provide as much context and examples as possible. If work on your _issue_ required an account credentials please provide them or explain how one can obtain them. I would like to know if it it possible to have Terminal automatically close the Window in use after it has successfully downloaded a batch file please?
Author
Owner

@siddht4 commented on GitHub (Aug 3, 2016):

do this as follows
create a batch file with the name test.bat
in the test.batch file add this commands
@echo off
youtube-dl [video-link]
exit

done

@siddht4 commented on GitHub (Aug 3, 2016): do this as follows create a batch file with the name test.bat in the test.batch file add this commands @echo off youtube-dl [video-link] exit done
Author
Owner

@siddht4 commented on GitHub (Aug 3, 2016):

for your example it would be

rename the test.txt to test.bat
test.txt

@siddht4 commented on GitHub (Aug 3, 2016): for your example it would be rename the test.txt to test.bat [test.txt](https://github.com/rg3/youtube-dl/files/400783/test.txt)
Author
Owner

@yan12125 commented on GitHub (Aug 4, 2016):

Thanks @siddht1 AFAIK it's impossible to close the terminal inside application. A shell script is the right way.

@yan12125 commented on GitHub (Aug 4, 2016): Thanks @siddht1 AFAIK it's impossible to close the terminal inside application. A shell script is the right way.
Author
Owner

@kwolk commented on GitHub (Aug 5, 2016):

Many thanks for the example, but I couldn't get your provided example file to work, I use the command:

youtube-dl --batch-file test.bat
AND
youtube-dl -a test.bat

I received the following error:

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

I tried of course without echo off but it wouldn't work either.

@kwolk commented on GitHub (Aug 5, 2016): Many thanks for the example, but I couldn't get your provided example file to work, I use the command: **youtube-dl --batch-file test.bat** AND **youtube-dl -a test.bat** I received the following error: _ERROR: u'@echo off' is not a valid URL. Set --default-search "ytsearch" (or run youtube-dl "ytsearch:@echo off" ) to search YouTube_ I tried of course without _echo off_ but it wouldn't work either.
Author
Owner

@yan12125 commented on GitHub (Aug 5, 2016):

Forgot to ask, are you using Windows? If so, just double click on test.bat.

@yan12125 commented on GitHub (Aug 5, 2016): Forgot to ask, are you using Windows? If so, just double click on `test.bat`.
Author
Owner

@kwolk commented on GitHub (Aug 5, 2016):

No, OS X, I skimmed past that in the documentation.

(Terminal is OS X, it's Command in Windows as I recall)

@kwolk commented on GitHub (Aug 5, 2016): No, OS X, I skimmed past that in the documentation. (Terminal is OS X, it's Command in Windows as I recall)
Author
Owner

@yan12125 commented on GitHub (Aug 5, 2016):

This should work:

youtube-dl "<the video URL>" && exit
@yan12125 commented on GitHub (Aug 5, 2016): This should work: ``` youtube-dl "<the video URL>" && exit ```
Author
Owner

@kwolk commented on GitHub (Aug 5, 2016):

That it does. Many thanks.

For clarification:

this is for OS X

  1. Create a text file in TextEdit (e.g. "zzz.txt") and save it to the Desktop.
  2. Enter all of the URLs of the YouTube videos you want to download inside zzz.txt one after the other on separate lines.
  3. Rename zzz.txt to zzz.bat --this is a batch file now.
  4. Open a Terminal window and type: youtube-dl -a ~/Desktop/zzz.bat && exit

Now all the videos in the text (batch) file will download and the Terminal window will close.

note: for the Terminal window to actually close you will need to follow this site's advice: http://superuser.com/questions/160473/avoiding-process-completed-prompt-after-terminal-script-ends-on-mac-os-x

@kwolk commented on GitHub (Aug 5, 2016): That it does. Many thanks. For clarification: **this is for OS X** 1. Create a text file in TextEdit (e.g. "zzz.txt") and save it to the Desktop. 2. Enter all of the URLs of the YouTube videos you want to download inside zzz.txt one after the other on separate lines. 3. Rename zzz.txt to zzz.bat --this is a batch file now. 4. Open a Terminal window and type: youtube-dl -a ~/Desktop/zzz.bat && exit Now all the videos in the text (batch) file will download and the Terminal window will close. _note: for the Terminal window to actually close you will need to follow this site's advice: http://superuser.com/questions/160473/avoiding-process-completed-prompt-after-terminal-script-ends-on-mac-os-x_
Author
Owner

@yan12125 commented on GitHub (Aug 5, 2016):

I guess you mean youtube-dl -a ~/Desktop/zzz.bat instead of youtube-dl ~/Desktop/zzz.bat in step 4?

@yan12125 commented on GitHub (Aug 5, 2016): I guess you mean `youtube-dl -a ~/Desktop/zzz.bat` instead of `youtube-dl ~/Desktop/zzz.bat` in step 4?
Author
Owner

@kwolk commented on GitHub (Aug 11, 2016):

Updated!

@kwolk commented on GitHub (Aug 11, 2016): Updated!
Author
Owner

@siddht4 commented on GitHub (Sep 2, 2016):

ok i thought you asked for windows as the title was "Automatically close Terminal window upon successful download?", i have the bash script for linux its similar as @yan12125 example

@siddht4 commented on GitHub (Sep 2, 2016): ok i thought you asked for windows as the title was "Automatically close Terminal window upon successful download?", i have the bash script for linux its similar as @yan12125 example
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/youtube-dl-ytdl-org#8350
No description provided.