• yt-dlp: How to auto-rename output files on conflicts?

    From VanguardLH@21:1/5 to All on Sun Jul 6 23:39:23 2025
    How do I get yt-dlp from overwriting an existing file, and instead
    append a number to create a new output file, so both the existing and
    next captured video still survive? Otherwise, yt-dlp just steps on the existing file.

    Say I go to site1 to capture dogbarking.mp4. I go to site2 where there
    is also dogbarking.mp4, but it is a different video with the same
    filename. I don't want yt-dlp to step on dogbarking.mp4 from site1 when
    I capture dogbarking.mp4 from site2, or even if I recapture multiple
    times the same dogbarking.mp4 video from the same site.

    I've tried the -o output template argument, like:

    yt-dlp.exe -o "%(title)s %(autonumber)s.%(ext)s" --no-overwrites <someURL>

    That has yt-dlp add a 5-digit number at the end of filename, like
    dogbarking 00001.mp4, from site1 but then the same filename is used at
    site2, so yt-dlp steps atop the existing file despite the
    --no-overwrites argument. Since autonumber ends up appending the same
    00001 to every output file, I suspect it is of use only when recursing
    through multiple video streams, like capturing from a playlist.

    What I'd like when capturing videos that happen to have the same
    filename at multiple sites is to end up with:

    dogbarking.mp4
    dogbarking (1).mp4
    dogbarking (2).mp4
    dogbarking (3).mp4

    or something similar. Same filename (since it is the same filename at
    each site), but differentiated by an appended index to avoid conflict.
    If there is an output file conflict, index the current output to prevent stepping on an existing same-named file.

    Or, is that a scheme of which yt-dlp is incapable, and I have to move
    from the command line to a GUI frontend that will handle the
    same-filename conflict?

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Paul@21:1/5 to VanguardLH on Mon Jul 7 04:17:21 2025
    On Mon, 7/7/2025 12:39 AM, VanguardLH wrote:
    How do I get yt-dlp from overwriting an existing file, and instead
    append a number to create a new output file, so both the existing and
    next captured video still survive? Otherwise, yt-dlp just steps on the existing file.

    Say I go to site1 to capture dogbarking.mp4. I go to site2 where there
    is also dogbarking.mp4, but it is a different video with the same
    filename. I don't want yt-dlp to step on dogbarking.mp4 from site1 when
    I capture dogbarking.mp4 from site2, or even if I recapture multiple
    times the same dogbarking.mp4 video from the same site.

    I've tried the -o output template argument, like:

    yt-dlp.exe -o "%(title)s %(autonumber)s.%(ext)s" --no-overwrites <someURL>

    That has yt-dlp add a 5-digit number at the end of filename, like
    dogbarking 00001.mp4, from site1 but then the same filename is used at
    site2, so yt-dlp steps atop the existing file despite the
    --no-overwrites argument. Since autonumber ends up appending the same
    00001 to every output file, I suspect it is of use only when recursing through multiple video streams, like capturing from a playlist.

    What I'd like when capturing videos that happen to have the same
    filename at multiple sites is to end up with:

    dogbarking.mp4
    dogbarking (1).mp4
    dogbarking (2).mp4
    dogbarking (3).mp4

    or something similar. Same filename (since it is the same filename at
    each site), but differentiated by an appended index to avoid conflict.
    If there is an output file conflict, index the current output to prevent stepping on an existing same-named file.

    Or, is that a scheme of which yt-dlp is incapable, and I have to move
    from the command line to a GUI frontend that will handle the
    same-filename conflict?


    Would there be an option to add a date-field instead of an
    autonumber ? That might make a slightly more unique identifier,
    except date fields don't go down to the second level.

    In a Google, I can see the autonumber start value can be assigned.
    But I don't know if that really helps matters.

    "Instead of %(playlist_index)s, you should use

    youtube-dl --autonumber-start 5 $URL -o "%(autonumber)s_stuff"

    It will start %(autonumber)s at 5 in this case.
    "

    You could also create a folder for each run, and
    store the output in the folder. Your script design
    would then control the folder name created just
    before the run.

    Paul

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From VanguardLH@21:1/5 to Paul on Mon Jul 7 08:19:11 2025
    Paul <nospam@needed.invalid> wrote:

    On Mon, 7/7/2025 12:39 AM, VanguardLH wrote:
    How do I get yt-dlp from overwriting an existing file, and instead
    append a number to create a new output file, so both the existing and
    next captured video still survive? Otherwise, yt-dlp just steps on the
    existing file.

    Say I go to site1 to capture dogbarking.mp4. I go to site2 where there
    is also dogbarking.mp4, but it is a different video with the same
    filename. I don't want yt-dlp to step on dogbarking.mp4 from site1 when
    I capture dogbarking.mp4 from site2, or even if I recapture multiple
    times the same dogbarking.mp4 video from the same site.

    I've tried the -o output template argument, like:

    yt-dlp.exe -o "%(title)s %(autonumber)s.%(ext)s" --no-overwrites <someURL> >>
    That has yt-dlp add a 5-digit number at the end of filename, like
    dogbarking 00001.mp4, from site1 but then the same filename is used at
    site2, so yt-dlp steps atop the existing file despite the
    --no-overwrites argument. Since autonumber ends up appending the same
    00001 to every output file, I suspect it is of use only when recursing
    through multiple video streams, like capturing from a playlist.

    What I'd like when capturing videos that happen to have the same
    filename at multiple sites is to end up with:

    dogbarking.mp4
    dogbarking (1).mp4
    dogbarking (2).mp4
    dogbarking (3).mp4

    or something similar. Same filename (since it is the same filename at
    each site), but differentiated by an appended index to avoid conflict.
    If there is an output file conflict, index the current output to prevent
    stepping on an existing same-named file.

    Or, is that a scheme of which yt-dlp is incapable, and I have to move
    from the command line to a GUI frontend that will handle the
    same-filename conflict?


    Would there be an option to add a date-field instead of an
    autonumber ? That might make a slightly more unique identifier,
    except date fields don't go down to the second level.

    In a Google, I can see the autonumber start value can be assigned.
    But I don't know if that really helps matters.

    "Instead of %(playlist_index)s, you should use

    youtube-dl --autonumber-start 5 $URL -o "%(autonumber)s_stuff"

    It will start %(autonumber)s at 5 in this case.
    "

    You could also create a folder for each run, and
    store the output in the folder. Your script design
    would then control the folder name created just
    before the run.

    Paul

    The problem with autonumber is it is not remembered between yt-dlp
    sessions. When I run yt-dlp the first time, yes, a number will get
    added to the filename, like 00001. Whenever I later run yt-dlp again, autonumber starts at 00001, so yt-dlp overwrites an existing file
    instead of increment to 00002.

    1st run: file = dogbarking 00001.mp4
    2nd run: file = dogbarking 00001.mp4 (overwrites existing file)

    As you noted, and I've read in yt-dlp's documentation, autonumber is
    oriented when you batch capture several videos. The indexing is not
    remembered between separate yt-dlp sessions. There is no filename
    collision avoidance in yt-dlp. Not even a pause to prompt on overwrite.

    I've tried a couple GUI frontends to yt-dlp, but they don't increment a
    numeric index if the output file already exists, either. Either they
    end up overwriting the existing file (and without prompting before overwriting), or they error (the video capture is lost). At best, in
    trying to avoid filename collisions, they may be optioned to save the
    videos in a folder named for the web site's domain, so the video is
    saved under <outputFolder>\<domain>\<filename>.

    That would provide collision avoidance when saving different videos at different sites that happen to have the same filename, but not if you
    save again the same video at the same site. I realize the next question
    is "Why save a duplicate of a video?" Actually that's not what I want.
    What I don't like is a capture that apparently either disappears
    (replaces an existing file) or aborts (the output file already exists)
    with me wondering why the output folder has not changed after a capture.

    I've used jaksta's Media Recorder (JMR) payware for a long time, but my
    license expired, and I need a new version that added a new extractor or modified one to work with several sites. When a capture fails, you send
    them a log, and they figure out how to fix by adding or modifying an
    extractor. yt-dlp does the same. I tested their latest version albeit trialware to verify they have new extractors; however, instead of paying
    for another 1-year license (or add $10 to get a 2-year license) of JMR,
    I decided to try yt-dlp. JMR would automatically increment a numeric
    suffix on a saved capture for filename collision avoidance. yt-dlp, and
    the GUI frontends for it that I tried, do not. They stop atop an
    existing file by the same name, or error during or at the end of the
    capture. Neither does yt-dlp pause at a prompt asking me if I want to overwrite an existing file by the same name. Even File Manager will
    prompt if I try to copy a file from one folder to another that already
    has a file by the same name. Even the 'copy' command will prompt on an overwrite (unless you use the /y parameter).

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Zaidy036@21:1/5 to VanguardLH on Mon Jul 7 11:59:19 2025
    On 7/7/2025 12:39 AM, VanguardLH wrote:
    How do I get yt-dlp from overwriting an existing file, and instead
    append a number to create a new output file, so both the existing and
    next captured video still survive? Otherwise, yt-dlp just steps on the existing file.

    Say I go to site1 to capture dogbarking.mp4. I go to site2 where there
    is also dogbarking.mp4, but it is a different video with the same
    filename. I don't want yt-dlp to step on dogbarking.mp4 from site1 when
    I capture dogbarking.mp4 from site2, or even if I recapture multiple
    times the same dogbarking.mp4 video from the same site.

    I've tried the -o output template argument, like:

    yt-dlp.exe -o "%(title)s %(autonumber)s.%(ext)s" --no-overwrites <someURL>

    That has yt-dlp add a 5-digit number at the end of filename, like
    dogbarking 00001.mp4, from site1 but then the same filename is used at
    site2, so yt-dlp steps atop the existing file despite the
    --no-overwrites argument. Since autonumber ends up appending the same
    00001 to every output file, I suspect it is of use only when recursing through multiple video streams, like capturing from a playlist.

    What I'd like when capturing videos that happen to have the same
    filename at multiple sites is to end up with:

    dogbarking.mp4
    dogbarking (1).mp4
    dogbarking (2).mp4
    dogbarking (3).mp4

    or something similar. Same filename (since it is the same filename at
    each site), but differentiated by an appended index to avoid conflict.
    If there is an output file conflict, index the current output to prevent stepping on an existing same-named file.

    Or, is that a scheme of which yt-dlp is incapable, and I have to move
    from the command line to a GUI frontend that will handle the
    same-filename conflict?

    I have never used yt-dlp but "filesystem Options" -w, --no-overwrites
    looks like what you want.

    Alternative is a batch which runs yt-dlp and uses SETX = SETX+1 as an
    index to be used for the next download.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From J. P. Gilliver@21:1/5 to VanguardLH on Mon Jul 7 16:31:35 2025
    On 2025/7/7 14:19:11, VanguardLH wrote:
    Paul <nospam@needed.invalid> wrote:

    On Mon, 7/7/2025 12:39 AM, VanguardLH wrote:
    How do I get yt-dlp from overwriting an existing file, and instead
    append a number to create a new output file, so both the existing and
    next captured video still survive? Otherwise, yt-dlp just steps on the
    existing file.

    Say I go to site1 to capture dogbarking.mp4. I go to site2 where there
    is also dogbarking.mp4, but it is a different video with the same
    filename. I don't want yt-dlp to step on dogbarking.mp4 from site1 when >>> I capture dogbarking.mp4 from site2, or even if I recapture multiple
    times the same dogbarking.mp4 video from the same site.

    I've tried the -o output template argument, like:

    yt-dlp.exe -o "%(title)s %(autonumber)s.%(ext)s" --no-overwrites <someURL> >>>
    That has yt-dlp add a 5-digit number at the end of filename, like
    dogbarking 00001.mp4, from site1 but then the same filename is used at
    site2, so yt-dlp steps atop the existing file despite the
    --no-overwrites argument. Since autonumber ends up appending the same
    00001 to every output file, I suspect it is of use only when recursing
    through multiple video streams, like capturing from a playlist.

    What I'd like when capturing videos that happen to have the same
    filename at multiple sites is to end up with:

    dogbarking.mp4
    dogbarking (1).mp4
    dogbarking (2).mp4
    dogbarking (3).mp4

    I have a strong memory of having seen that happen, without my doing
    anything! (I have "20225.06.30", though I know I did an update recently
    and the (1) etc. would have been earlier. I've just checked and that's
    still the current version.) Not that I can remember ever trying to get a
    video of the same name from a second site while the first one was still
    in the directory. (I have D:\videos\yt-dlp - no spaces - for its
    downloads, and always move the file almost as soon as I've downloaded
    it, so would be unlikely to have the problem. I have it in its own
    folder - one without any spaces in the pathname - because I discovered,
    many versions ago, that the update [-U] function worked by creating a
    batch file [which it then runs and deletes], and having spaces in the
    path breaks that; I don't know if that still applies.)

    I have _sometimes_ seen - when downloading the same file a _second_
    time, sort of by accident - it say something like "... already
    downloaded", and not download it again. This has mainly, recently, been
    where it has downloaded two files (I think video and audio), and when I
    do the download again including the --ffmpeglocation option to join
    them, I get that message for one of the components. (Finding it has
    downloaded a file in two parts like that is usually a prompt to run a -U update.)>>>
    or something similar. Same filename (since it is the same filename at
    each site), but differentiated by an appended index to avoid conflict.
    If there is an output file conflict, index the current output to prevent >>> stepping on an existing same-named file.

    Or, is that a scheme of which yt-dlp is incapable, and I have to move
    from the command line to a GUI frontend that will handle the
    same-filename conflict?

    As I say, I _think_ I have seen that, so I think it is possible. No idea
    how to invoke it though! I mostly just use it bare - "y <URL>" (I've
    renamed it to just y.exe; the -U option still works, creating the new
    y.exe!) - only using other parameters if I want subtitles or something.

    []

    The problem with autonumber is it is not remembered between yt-dlp
    sessions. When I run yt-dlp the first time, yes, a number will get
    added to the filename, like 00001. Whenever I later run yt-dlp again, autonumber starts at 00001, so yt-dlp overwrites an existing file
    instead of increment to 00002.

    1st run: file = dogbarking 00001.mp4
    2nd run: file = dogbarking 00001.mp4 (overwrites existing file)

    Maybe there's an ask-before-overwriting switch? (or a
    turn-off-overwriting one?)

    As you noted, and I've read in yt-dlp's documentation, autonumber is
    oriented when you batch capture several videos. The indexing is not remembered between separate yt-dlp sessions. There is no filename
    collision avoidance in yt-dlp. Not even a pause to prompt on overwrite.

    Is there a way of storing y's settings in a file (like a .ini file), so
    you could store the autonumber seed? (No, hang on, that wouldn't help,
    would it? It would still store the same seed! But it would if either of
    the switches I've asked about exist.)

    I've tried a couple GUI frontends to yt-dlp, but they don't increment a numeric index if the output file already exists, either. Either they
    end up overwriting the existing file (and without prompting before overwriting), or they error (the video capture is lost). At best, in
    trying to avoid filename collisions, they may be optioned to save the
    videos in a folder named for the web site's domain, so the video is
    saved under <outputFolder>\<domain>\<filename>.

    Clumsy workaround: could you make a batch file (yget %1 %2) that always
    gets %1 to some fixed filename, then renames that fixed filename to %2?
    The rename would - I _think_! - then crash out because the file already
    exists, but at least you'd not lose the download.>
    That would provide collision avoidance when saving different videos at different sites that happen to have the same filename, but not if you
    save again the same video at the same site. I realize the next question
    is "Why save a duplicate of a video?" Actually that's not what I want.

    (I've sometimes wanted to save it in more than one format, resolution,
    or similar.)
    []

    overwrite an existing file by the same name. Even File Manager will
    prompt if I try to copy a file from one folder to another that already
    has a file by the same name. Even the 'copy' command will prompt on an overwrite (unless you use the /y parameter).
    I'm pretty sure yt-dlp is very low-level, i. e. does its file management itself, rather than calling Windows functions - I'm not sure what it's
    written in, but I think the fact that it's available for Windows and
    assorted other OSs means it's low-level. And they've decided not to
    implement checking of that sort.
    Final thought: you could have a batch (yget %1 %2) that first did a copy
    (or move) of %2 to a temporary folder (using a suppression switch to
    ignore "doesn't exist"), then got %1 to %2; that way you wouldn't lose
    an old %2 if it existed - you'd just have to remeber to empty the
    temporary directory occasionally.

    No, that wouldn't work - well, it would, but I can see you want to use
    y's automatic filename generation function rather than specifying %2
    anyway. Good problem!(If there _isn't_ a --prompt-before-overwiting or
    similar switch, is there some _Windows_ function that could save and
    increment a number as a system variable, so you could pass %count% or
    similar to y as the autonumber seed?)
    By the way, there is a comp.internet.services.video.youtube newsgroup;
    it's fairly quiet. I haven't crossposted to it, as I don't want to
    remind YouTube (Google, isn't it?) that yt-dlp exists, though I'm sure
    they are aware of it.
    --
    J. P. Gilliver. UMRA: 1960/<1985 MB++G()AL-IS-Ch++(p)Ar@T+H+Sh0!:`)DNAf

    We'd agreed to overlook each others' families and everything, and get
    married" (The Trouble with Harry)

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From VanguardLH@21:1/5 to Zaidy036@air.isp.spam on Tue Jul 8 09:49:13 2025
    Zaidy036 <Zaidy036@air.isp.spam> wrote:

    On 7/7/2025 12:39 AM, VanguardLH wrote:
    How do I get yt-dlp from overwriting an existing file, and instead
    append a number to create a new output file, so both the existing and
    next captured video still survive? Otherwise, yt-dlp just steps on the
    existing file.

    Say I go to site1 to capture dogbarking.mp4. I go to site2 where there
    is also dogbarking.mp4, but it is a different video with the same
    filename. I don't want yt-dlp to step on dogbarking.mp4 from site1 when
    I capture dogbarking.mp4 from site2, or even if I recapture multiple
    times the same dogbarking.mp4 video from the same site.

    I've tried the -o output template argument, like:

    yt-dlp.exe -o "%(title)s %(autonumber)s.%(ext)s" --no-overwrites <someURL> >>
    That has yt-dlp add a 5-digit number at the end of filename, like
    dogbarking 00001.mp4, from site1 but then the same filename is used at
    site2, so yt-dlp steps atop the existing file despite the
    --no-overwrites argument. Since autonumber ends up appending the same
    00001 to every output file, I suspect it is of use only when recursing
    through multiple video streams, like capturing from a playlist.

    What I'd like when capturing videos that happen to have the same
    filename at multiple sites is to end up with:

    dogbarking.mp4
    dogbarking (1).mp4
    dogbarking (2).mp4
    dogbarking (3).mp4

    or something similar. Same filename (since it is the same filename at
    each site), but differentiated by an appended index to avoid conflict.
    If there is an output file conflict, index the current output to prevent
    stepping on an existing same-named file.

    Or, is that a scheme of which yt-dlp is incapable, and I have to move
    from the command line to a GUI frontend that will handle the
    same-filename conflict?

    I have never used yt-dlp but "filesystem Options" -w, --no-overwrites
    looks like what you want.

    Doesn't help. yt-dlp still does the download (into temp files), and
    then saves to an output file. yt-dlp would waste the time and bandwidth
    to get the video only to abort at the end with the output file write.
    Yeah, in a way, it prevents filename collisions, but that's by not
    writing at all.

    Alternative is a batch which runs yt-dlp and uses SETX = SETX+1 as an
    index to be used for the next download.

    Thanks for mention of the set command to increment an envvar, but that
    would work only when running multiple sequential yt-dlp commands within
    the same session (i.e., inside the same shell). After doing a download,
    I close the console window (cmd shell), so envvars are lost, and I
    really don't want to attempt to set global envvars to keep track across
    shells. The next time I load the shell to run yt-dlp again, setx would
    start undefined (nul), would increment, but would not prevent a filename collision on an existing file. My script would have to add code
    checking if the file exists, and then do some post-downloading code.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From VanguardLH@21:1/5 to All on Tue Jul 8 09:43:20 2025
    It isn't just a problem of [accidentally or deliberately] downloading
    the same video (and same output filename) at the same site, but also of different sites with different videos having the same filename. There
    is no coordination between sites on filenames. One site could have a
    video named xyz.mp4, and so could another site, but different videos.

    I did find the --no-overwrite command-line switch to yt-dlp, but there
    is no prompt, the overwrite aborts, but yt-dlp still does the download
    because it is using temporary files to build the output. So, as the
    switch says, it prevents yt-dlp from overwriting an existing file, not
    from spending the time and bandwidth doing the download. There are a
    LOT of sommand-line switches and arguments to yt-dlp, so I can see why
    many users want a GUI frontend to it. Tis possible I missed one in the documentation at https://github.com/yt-dlp/yt-dlp.

    I'm using a batch file now to run yt-dlp from the command line. I might
    add some post-processing commands to affix an index number to the just downloaded file, and the script would check if the index was already the
    file to up the index, like run through a for-loop. yt-dlp would still
    download and create a new file, but it wouldn't have an index, so yt-dlp wouldn't be stepping on a prior download. Basically the script would do
    some file renaming after the download after checking errorlevel from
    yt-dlp to check it actually did a download.

    The date/time switches in yt-dlp are apparently the values in the
    metadata for the video which would be the same on a subsequent reload
    from the same site, but would very likely be different for the
    same-named video at different web sites. Adding metadata
    date/timestamps would eliminate output file collisions across sites for same-named videos, but not at the same site. I haven't yet figured out
    just what the epoch var is supposed to add (from video metadata, or when
    yt-dlp created the local file?), like adding %(epoch>%Y%m%d%H%M%S)s to
    the --output argument in the template for naming the output file. The
    docs say:

    epoch (numeric): Unix epoch of when the information extraction was
    completed

    Maybe that is when yt-dlp extracted the metadata from the video, so it
    would be a local timestamp just before yt-dlp downloaded the video. If granularity is down to the second then output filename collision might
    be avoided.

    Copying a web page's URL from the web browser, and pasting into the
    command line is about all I want to do at the command line to run
    yt-dlp. Even then, when pasting, I have to add double quotes around the
    URL pasted into the command line to ensure the command line parser
    doesn't see any ampersands (&) in the URL since that is a valid
    character to separate arguments in the URL, but also a valid delimiter
    between commands in the same command line. So, at the command line:
    enter yt (the filename of the batch file in the C:\Batch folder in the
    PATH envvar), a space and ", paste the URL, another ", and hit Enter.
    Any more stuff I have to enter in the command line reduces convenience,
    and pushes me toward using a frontend GUI for yt-dlp.

    I'm new at using yt-dlp directly, and haven't yet figured out how or why
    I need ffmpeg in the mix other than perhaps to merge video and audio
    streams for post-processing (apparently for some videos at Youtube, and
    other sites, those can be separate streams), for what I would need
    ffprobe. I haven't hit any sites with multiple videos per page to see
    how yt-dlp handles that. I have found yt-dlp won't work at some sites,
    but, so far, those are where the site uses its own Javascripted viewer delivered with the web page, and the site ensures the video is encrypted
    or otherwise encoded where only their JS viewer code can decipher the
    video. They trying to implement a DRM scheme using Javascript, and some
    key that only their scripted viewer has. The jaksta Media Recorder that
    I used before would require I switch into its Auto mode which would
    detect the video, and capture the streams another way. It could also
    screen scrape to capture the video from the screen, but could result in artifacts, like the mouse pointer moving across the video, halts and
    jitters in the playback, or video streams that get paused to push an ad
    stream afterwhich the video stream resumes.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Zaidy036@21:1/5 to VanguardLH on Tue Jul 8 11:03:06 2025
    On 7/8/2025 10:49 AM, VanguardLH wrote:
    Zaidy036 <Zaidy036@air.isp.spam> wrote:

    On 7/7/2025 12:39 AM, VanguardLH wrote:
    How do I get yt-dlp from overwriting an existing file, and instead
    append a number to create a new output file, so both the existing and
    next captured video still survive? Otherwise, yt-dlp just steps on the
    existing file.

    Say I go to site1 to capture dogbarking.mp4. I go to site2 where there
    is also dogbarking.mp4, but it is a different video with the same
    filename. I don't want yt-dlp to step on dogbarking.mp4 from site1 when >>> I capture dogbarking.mp4 from site2, or even if I recapture multiple
    times the same dogbarking.mp4 video from the same site.

    I've tried the -o output template argument, like:

    yt-dlp.exe -o "%(title)s %(autonumber)s.%(ext)s" --no-overwrites <someURL> >>>
    That has yt-dlp add a 5-digit number at the end of filename, like
    dogbarking 00001.mp4, from site1 but then the same filename is used at
    site2, so yt-dlp steps atop the existing file despite the
    --no-overwrites argument. Since autonumber ends up appending the same
    00001 to every output file, I suspect it is of use only when recursing
    through multiple video streams, like capturing from a playlist.

    What I'd like when capturing videos that happen to have the same
    filename at multiple sites is to end up with:

    dogbarking.mp4
    dogbarking (1).mp4
    dogbarking (2).mp4
    dogbarking (3).mp4

    or something similar. Same filename (since it is the same filename at
    each site), but differentiated by an appended index to avoid conflict.
    If there is an output file conflict, index the current output to prevent >>> stepping on an existing same-named file.

    Or, is that a scheme of which yt-dlp is incapable, and I have to move
    from the command line to a GUI frontend that will handle the
    same-filename conflict?

    I have never used yt-dlp but "filesystem Options" -w, --no-overwrites
    looks like what you want.

    Doesn't help. yt-dlp still does the download (into temp files), and
    then saves to an output file. yt-dlp would waste the time and bandwidth
    to get the video only to abort at the end with the output file write.
    Yeah, in a way, it prevents filename collisions, but that's by not
    writing at all.

    Alternative is a batch which runs yt-dlp and uses SETX = SETX+1 as an
    index to be used for the next download.

    Thanks for mention of the set command to increment an envvar, but that
    would work only when running multiple sequential yt-dlp commands within
    the same session (i.e., inside the same shell). After doing a download,
    I close the console window (cmd shell), so envvars are lost, and I
    really don't want to attempt to set global envvars to keep track across shells. The next time I load the shell to run yt-dlp again, setx would
    start undefined (nul), would increment, but would not prevent a filename collision on an existing file. My script would have to add code
    checking if the file exists, and then do some post-downloading code.
    SetX is environmental and maintained for use by following runs of any
    program or batch and not affected even by shut downs but only by
    specific commands

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Java Jive@21:1/5 to VanguardLH on Tue Jul 8 17:01:16 2025
    On 2025-07-07 05:39, VanguardLH wrote:

    How do I get yt-dlp from overwriting an existing file, and instead
    append a number to create a new output file, so both the existing and
    next captured video still survive? Otherwise, yt-dlp just steps on the existing file.

    Whenever in the past I've used You-TubeDL or You-TubeDL+ I get a
    filename where the random number key from the original YouTube video URL
    is appended to the filename in square brackets. As these numbers are
    unique, why not just leave them in the filename to avoid the problem you describe?

    For a real example ...

    Chris Norman - Blame It On My Jealous Heart https://www.youtube.com/watch?v=TL0bxtX35Ng

    ... results in (after renaming by myself)

    Chris Norman - Jealous Heart (official video) [TL0bxtX35Ng].webm

    --

    Fake news kills!

    I may be contacted via the contact address given on my website:
    www.macfh.co.uk

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From VanguardLH@21:1/5 to Zaidy036@air.isp.spam on Tue Jul 8 11:58:38 2025
    Zaidy036 <Zaidy036@air.isp.spam> wrote:

    VanguardLH wrote:

    Zaidy036 <Zaidy036@air.isp.spam> wrote:

    Alternative is a batch which runs yt-dlp and uses SETX = SETX+1 as
    an index to be used for the next download.

    Thanks for mention of the set command to increment an envvar, but
    that would work only when running multiple sequential yt-dlp
    commands within the same session (i.e., inside the same shell).
    After doing a download, I close the console window (cmd shell), so
    envvars are lost, and I really don't want to attempt to set global
    envvars to keep track across shells. The next time I load the shell
    to run yt-dlp again, setx would start undefined (nul), would
    increment, but would not prevent a filename collision on an existing
    file. My script would have to add code checking if the file exists,
    and then do some post-downloading code.

    SetX is environmental and maintained for use by following runs of any
    program or batch and not affected even by shut downs but only by
    specific commands

    setx=setx+1
    Error: Invalid sytax.

    setx = setx+1
    ERROR: The name of an environment variable cannot include an equal sign (=).

    Don't remember using setx, or it has been way too long since previously
    used, so I ran "setx /?" to find out how to use it. Your syntax is
    invalid for setx, but is valid for set (not setx) for a local envvar
    within a shell, like:

    set vname=0
    set /a vname=%vname% + 1 > nul
    echo %vname%

    The /a switch is needed for the set command to do arithmetic; i.e, /a
    makes set evaluate an expression. envvars are always strings, even
    'set var=0' or 'setx var 0' has var hold a string of "0", not a numeric
    value of zero. Alas, a defect with /a is it also echoes out the
    evaluated value which can be confusing in the stdout of the batch
    script, so I redirect stdout for 'set /a' to nul.

    setx defines global envvars, but does not update the current shell to
    use the new envvar perhaps to delayed execution, by default, in commands
    ran in a shell. The envvar gets defined, but envvars are loaded when a
    shell loads, so the envvar is available in later shells.

    "On a local system, variables created or modified by this tool will be
    available in future command windows but not in the current CMD.exe
    command window."
    (from "setx /?")

    setx has no /a switch to make it evaluate a string as an expression, so
    I'd have to add var to the envvar list beforehand, like use sysdm.cpl to
    add a new envvar, or run a batch script as a startup item on login to
    run, say:

    setx vname_global 1

    and call a batch script using:

    yt "<url>"

    where the double-quotes must be added to prevent the command-line parser
    from seeing any ampersands (&) in the URL used to delineate arguments in
    the URL, and where the script did:

    ytp-dl.exe --output <template> %1
    set /a vname_local=%vname_global% + 1 > nul
    setx vname_global %vname_local%

    I would still need to figure out the syntax for <template>, but it would include vname_global to index the output file created by yt-dlp to help
    to avoid filename collisions.

    So, setx could be used to track indexing across separate command shells,
    but, boy, it can get confusing to maintain the script, and relies on a
    global envvar that I'd like to avoid just to workaround not recognizing
    a file already exists by the same name, and affix an index onto the
    output file. Rather than bother with a global envvar (which I would
    have to remember since other batch script or programs could possibly
    step on the same name for the envvar), I can add post-processing code to
    the the batch script to avoid the filename collisions that yt-dlp
    doesn't avoid, and neither do the GUI frontends. I've hunted through
    the vast list of command-line args and switches to yt-dlp, but don't see anything to avoid filename collisions, and from what I've found posted
    by others seems a common affliction with yt-dlp.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Java Jive@21:1/5 to VanguardLH on Tue Jul 8 19:31:34 2025
    On 2025-07-08 17:58, VanguardLH wrote:

    setx=setx+1
    Error: Invalid sytax.

    setx = setx+1
    ERROR: The name of an environment variable cannot include an equal sign (=).

    SETX /?

    --

    Fake news kills!

    I may be contacted via the contact address given on my website:
    www.macfh.co.uk

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Zaidy036@21:1/5 to VanguardLH on Tue Jul 8 16:22:53 2025
    On 7/8/2025 12:58 PM, VanguardLH wrote:
    Zaidy036 <Zaidy036@air.isp.spam> wrote:

    VanguardLH wrote:

    Zaidy036 <Zaidy036@air.isp.spam> wrote:

    Alternative is a batch which runs yt-dlp and uses SETX = SETX+1 as
    an index to be used for the next download.

    Thanks for mention of the set command to increment an envvar, but
    that would work only when running multiple sequential yt-dlp
    commands within the same session (i.e., inside the same shell).
    After doing a download, I close the console window (cmd shell), so
    envvars are lost, and I really don't want to attempt to set global
    envvars to keep track across shells. The next time I load the shell
    to run yt-dlp again, setx would start undefined (nul), would
    increment, but would not prevent a filename collision on an existing
    file. My script would have to add code checking if the file exists,
    and then do some post-downloading code.

    SetX is environmental and maintained for use by following runs of any
    program or batch and not affected even by shut downs but only by
    specific commands

    setx=setx+1
    Error: Invalid sytax.

    setx = setx+1
    ERROR: The name of an environment variable cannot include an equal sign (=).

    Don't remember using setx, or it has been way too long since previously
    used, so I ran "setx /?" to find out how to use it. Your syntax is
    invalid for setx, but is valid for set (not setx) for a local envvar
    within a shell, like:

    set vname=0
    set /a vname=%vname% + 1 > nul
    echo %vname%

    The /a switch is needed for the set command to do arithmetic; i.e, /a
    makes set evaluate an expression. envvars are always strings, even
    'set var=0' or 'setx var 0' has var hold a string of "0", not a numeric
    value of zero. Alas, a defect with /a is it also echoes out the
    evaluated value which can be confusing in the stdout of the batch
    script, so I redirect stdout for 'set /a' to nul.

    setx defines global envvars, but does not update the current shell to
    use the new envvar perhaps to delayed execution, by default, in commands
    ran in a shell. The envvar gets defined, but envvars are loaded when a
    shell loads, so the envvar is available in later shells.

    "On a local system, variables created or modified by this tool will be
    available in future command windows but not in the current CMD.exe
    command window."
    (from "setx /?")

    setx has no /a switch to make it evaluate a string as an expression, so
    I'd have to add var to the envvar list beforehand, like use sysdm.cpl to
    add a new envvar, or run a batch script as a startup item on login to
    run, say:

    setx vname_global 1

    and call a batch script using:

    yt "<url>"

    where the double-quotes must be added to prevent the command-line parser
    from seeing any ampersands (&) in the URL used to delineate arguments in
    the URL, and where the script did:

    ytp-dl.exe --output <template> %1
    set /a vname_local=%vname_global% + 1 > nul
    setx vname_global %vname_local%

    I would still need to figure out the syntax for <template>, but it would include vname_global to index the output file created by yt-dlp to help
    to avoid filename collisions.

    So, setx could be used to track indexing across separate command shells,
    but, boy, it can get confusing to maintain the script, and relies on a
    global envvar that I'd like to avoid just to workaround not recognizing
    a file already exists by the same name, and affix an index onto the
    output file. Rather than bother with a global envvar (which I would
    have to remember since other batch script or programs could possibly
    step on the same name for the envvar), I can add post-processing code to
    the the batch script to avoid the filename collisions that yt-dlp
    doesn't avoid, and neither do the GUI frontends. I've hunted through
    the vast list of command-line args and switches to yt-dlp, but don't see anything to avoid filename collisions, and from what I've found posted
    by others seems a common affliction with yt-dlp.

    Sorry but I was just talking about the logic flow and not the batch
    commands themselves.

    So don't use SETX but rather let yt-dlp download into a specified folder followed by batch commands to transfer into the "real" folder you want
    it in. If there is a name collision then the transfer will error and can
    ask what name would you like to use or just cycle thru its name with an
    added letter or number until the transfer succeeds.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From VanguardLH@21:1/5 to Zaidy036@air.isp.spam on Tue Jul 8 17:36:33 2025
    Zaidy036 <Zaidy036@air.isp.spam> wrote:

    Sorry but I was just talking about the logic flow and not the batch
    commands themselves.

    So don't use SETX but rather let yt-dlp download into a specified folder followed by batch commands to transfer into the "real" folder you want
    it in. If there is a name collision then the transfer will error and can
    ask what name would you like to use or just cycle thru its name with an
    added letter or number until the transfer succeeds.

    That's what I figure to do in the batch script: try to save, if error
    then append an incremented number, and repeat until eventually the
    number is high enough to make the filename unique. Actually I'll first
    test in a for-loop IF EXISTS on the file and, if so, repeat until fail,
    and then append the current number to the filename using rename.

    Thanks for the clue.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From VanguardLH@21:1/5 to Java Jive on Tue Jul 8 17:54:56 2025
    Java Jive <java@evij.com.invalid> wrote:

    On 2025-07-07 05:39, VanguardLH wrote:

    How do I get yt-dlp from overwriting an existing file, and instead
    append a number to create a new output file, so both the existing and
    next captured video still survive? Otherwise, yt-dlp just steps on the
    existing file.

    Whenever in the past I've used You-TubeDL or You-TubeDL+ I get a
    filename where the random number key from the original YouTube video URL
    is appended to the filename in square brackets. As these numbers are
    unique, why not just leave them in the filename to avoid the problem you describe?

    For a real example ...

    Chris Norman - Blame It On My Jealous Heart https://www.youtube.com/watch?v=TL0bxtX35Ng

    ... results in (after renaming by myself)

    Chris Norman - Jealous Heart (official video) [TL0bxtX35Ng].webm

    Youtube adds an id to the metadata of a video. Other sites may not. I
    did see the --output <template> argument where you could specify %(id)s
    in the template to add the id to the output filename, but that works
    only if an id is added to the file/stream's metadata. If there is no
    metadata, or no id attribute in the metadata, you end up a null string
    and two brackets side by side ("[]").

    Or are you talking about video ID in the URL? Youtube does that, but
    not all other sites.

    I don't capture much from Youtube. I've captured one cutest kitten YT
    video that I then e-mailed to my aunt that has cats, but there isn't
    much at Youtube of value to me. It is other sites where I grab videos I
    may want to archive for reference, or fear they will disappear figuring
    I might later want to reference them to others. For example, the author
    of OAUTH (1 and 2), Eran Hammer, has a video at Vimeo about how OAUTH
    was a protocol, OAUTH2 became a framework, why OAUTH2 sucks, and he
    apologizes for participating in the OAUTH2 mess.

    https://vimeo.com/52882780

    Yeah, no surprise the video can't be hosted at Youtube. One day the
    video could disappear from Vimeo, so I captured a copy of it. I grin
    when I listen to it again.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From VanguardLH@21:1/5 to Java Jive on Tue Jul 8 17:32:40 2025
    Java Jive <java@evij.com.invalid> wrote:

    VanguardLH wrote:

    setx=setx+1
    Error: Invalid sytax.

    setx = setx+1
    ERROR: The name of an environment variable cannot include an equal sign (=).

    SETX /?

    Yep, I mentioned that right afterward in the part you snipped. An equal
    sign is invalid syntax, and you don't increment the command.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From VanguardLH@21:1/5 to VanguardLH on Wed Jul 9 09:50:09 2025
    VanguardLH <V@nguard.LH> wrote:

    How do I get yt-dlp from overwriting an existing file, and instead
    append a number to create a new output file, so both the existing and
    next captured video still survive? Otherwise, yt-dlp just steps on the existing file.

    Say I go to site1 to capture dogbarking.mp4. I go to site2 where there
    is also dogbarking.mp4, but it is a different video with the same
    filename. I don't want yt-dlp to step on dogbarking.mp4 from site1 when
    I capture dogbarking.mp4 from site2, or even if I recapture multiple
    times the same dogbarking.mp4 video from the same site.

    I've tried the -o output template argument, like:

    yt-dlp.exe -o "%(title)s %(autonumber)s.%(ext)s" --no-overwrites <someURL>

    That has yt-dlp add a 5-digit number at the end of filename, like
    dogbarking 00001.mp4, from site1 but then the same filename is used at
    site2, so yt-dlp steps atop the existing file despite the
    --no-overwrites argument. Since autonumber ends up appending the same
    00001 to every output file, I suspect it is of use only when recursing through multiple video streams, like capturing from a playlist.

    What I'd like when capturing videos that happen to have the same
    filename at multiple sites is to end up with:

    dogbarking.mp4
    dogbarking (1).mp4
    dogbarking (2).mp4
    dogbarking (3).mp4

    or something similar. Same filename (since it is the same filename at
    each site), but differentiated by an appended index to avoid conflict.
    If there is an output file conflict, index the current output to prevent stepping on an existing same-named file.

    Or, is that a scheme of which yt-dlp is incapable, and I have to move
    from the command line to a GUI frontend that will handle the
    same-filename conflict?

    Been hunting around, and reading more on all the args to yt-dlp, and
    found one that might work without me having to code a bunch of tests and incrementing vars in the batch script used to run yt-dlp. It's called
    epoch to get the date & time when a video was captured. There are other date/timestamp args to yt-dlp, but they're for metadata or server-side attributes on the file/stream. epoch gives me a timestamp of now (well,
    when the video got captured) down to the second. I figure between
    having enter yt "<pasteURL>" into the command line, and for an
    extraction of the video that more than a second would elapse. So, I use
    the --output arg to specify the output filename as:

    --output "%%(title)s_%%(epoch>%%Y%%m%%d%%H%%M%%S)s.%%(ext)s"

    The doubled percent signs is needed in a batch file. % is used to
    escape a %, so %% becomes a % after parsing, and the varnames and
    strftime qualifiers also need the escaped (doubled) % to denote a
    varname and the year, month, day, hour, minute, second format for the
    epoch timestamp.

    I also added the --restrict-filenames argument to eliminate non-ASCII characters in the output filename, and it looks like it also converts
    spaces into underscores.

    Looks like I can use epoch down to the second to avoid filename
    collisions. I saw other folks using other vars to use in folder
    creating and naming to separate downloads from different sites which
    would avoid filename collisions, but that wouldn't help when downloading
    the same video from the same site.

    Instead of indexing duplicate output files, I'll timestamp them. No
    having to write, and debug code in the batch script to ensure unique
    filenames.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)