Is there a no clobber option? (do not overwrite file)

Discussion of the HandBrake command line interface (CLI)
Forum rules
An Activity Log is required for support requests. Please read How-to get an activity log? for details on how and why this should be provided.
Post Reply
winterheat
Posts: 37
Joined: Wed May 12, 2010 10:02 am

Is there a no clobber option? (do not overwrite file)

Post by winterheat »

Say, if I have an alias in Bash on the Mac as

Code: Select all

HandBrakeCLI -O -o ~/Desktop/output.mp4 -i 
I might encode something for 20 minutes and then found another clip, and use the command above again, only that HandBrake CLI will overwrite the existing file and if I need that file, I will have to encode it again. I can check first whether this file exist or not but if in that folder there are 50 files already, then it will be hard to check and that I may actually miss the file. Does HandBrake CLI have any option to stop the encoding when the file already exist, just like HandBrake GUI, which will ask if you want to overwrite the file or not?
mduell
Veteran User
Posts: 8198
Joined: Sat Apr 21, 2007 8:54 pm

Re: Is there a no clobber option? (do not overwrite file)

Post by mduell »

No, the CLI assumes you actually want to do what you're telling it to do.
winterheat
Posts: 37
Joined: Wed May 12, 2010 10:02 am

Re: Is there a no clobber option? (do not overwrite file)

Post by winterheat »

I mean even the HandBrake GUI can assume you actually want to do what you're telling it to do, and overwrite the file. Just like Word's Save As can assume you actually... and cp in UNIX can assume you actually... (but UNIX's cp has a no clobber option). So actually, I do want to do that, but it is more like what you actually want to do might have side effect (overwrite a file), and "do you want to proceed anyway?"
Deleted User 11865

Re: Is there a no clobber option? (do not overwrite file)

Post by Deleted User 11865 »

We don't have any such option. Patches welcome.
AlBundy
Bright Spark User
Posts: 377
Joined: Mon Dec 31, 2012 4:47 am

Re: Is there a no clobber option? (do not overwrite file)

Post by AlBundy »

You could use a bash script instead of an alias.
Something like this (untested)

Code: Select all

#! /bin/bash

if [ - e "$1" ]; then
   echo "file already exists" 
else
   HandBrakeCLI -O -o ~/Desktop/output.mp4 -i "$1"
fi

Post Reply