Page 1 of 1

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

Posted: Sat Apr 11, 2015 8:29 pm
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?

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

Posted: Sat Apr 11, 2015 8:32 pm
by mduell
No, the CLI assumes you actually want to do what you're telling it to do.

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

Posted: Sat Apr 11, 2015 8:49 pm
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?"

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

Posted: Sun Apr 12, 2015 6:36 pm
by Deleted User 11865
We don't have any such option. Patches welcome.

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

Posted: Tue Apr 14, 2015 11:20 pm
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