[SOLVED] ffmpeg - want it to convert/rename/batch, don't overwrite or ask to
Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
ffmpeg - want it to convert/rename/batch, don't overwrite or ask to
Hello,
here are my files:
a.flv
a.mp4
b.flv
c.flv
I would like to have ffmpeg convert flv files to mp4 if there is not one, rename them, then move on to the next flv. if it finds that an mp4 already exists with the same name, I don't want it to ask, and I don't want it to overwrite.
I have a command script, but it stops to ask to overwrite. in the example above, it will ask about a.flv
I want ffmpeg to skip a.flv (because there is already a.mp4) and move on to b.flv, then c.flv
here is my script (it works great, except for the overwrite issue):
for file in *.flv
do
ffmpeg -i $file -sameq ${file%%.*}.mp4
done
I realize that ffmpeg is supposed to work with the -n option, I tried the -n option (perhaps a mistake on my part, I hope someone points out where I went wrong) and got an error:
Unrecognized option 'n'
Failed to set value 'thefile.flv' for option 'n'
here is what that failed script looks like. I assumed just change the i to n
for file in *.flv
do
ffmpeg -n $file -sameq ${file%%.*}.mp4
done
it's possible that I have an older version of ffmpeg, and the n option is not included. I would rather not uninstall/reinstall if possible. instead I have a little chunk of code that may help. I don't know how it would be implimented, or if there is any way to make it work correctly. I read something about curved brackets and a colon could be used.
echo "n" | <some command to ask you y/n>
can this little piece of code be merged into my script successfully?
I think you may misunderstand what I need (my fault).
I'm converting/renaming hundreds of flv files to mp4, and many already have an eqivalent/converted mp4, so instead of the terminal wasting time converting them (overwriting them is converting them again, isn't it?) I want the command to also state that if there already is a mp4 file of that name, don't ask to overwrite, and don't overwrite. ultimately what I want the command to do is make sure that each flv has a mp4 and does it without intervention or overwriting. I can leave it go overnight and it would get as much done if possible, if not all.
off-topic:
you probably didn't notice, but you provided me with that command years ago. it works great for batch converting and renaming flv files to mp4.
I tried the command you provided in a test folder. it worked great. it skipped over flv's with mp4's already present and converted those without. didn't say a word until done.
I have every reason to believe that it will always work without a problem, but I would like to leave the thread open for a couple of days in case I (or others) have other thoughts.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.