By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,053 Members | 1,165 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,053 IT Pros & Developers. It's quick & easy.

overwrite file without asking

P: 63
Hi,
I have a script that convert a file, "$novo" in this case, to a 3gp file:
this is part of the script:

Expand|Select|Wrap|Line Numbers
  1.  
  2. print "qual é o título da peça? (< 36 caracteres)\n";
  3. my $titul=<STDIN>;
  4. chomp($titul);
  5.  
  6. my $outputgprs="$titul"."_25".".3gp";    
  7.  
  8. system "ffmpeg -i '$novo' -acodec libamr_nb -ar 8000 -ac 1 -r 7 -b 25k -s 176x144 -vcodec h263 -ab 7.95k /home/user/Desktop/$outputgprs"; 
Obviously, before I already put the file to convert in "$novo". Didn't write all the code to save space.

My problem here is that sometimes already exists a file with the same name of the target file. When this happens, ffmpeg asks something like: "Do you want to overwrite the file ....?"
I'd like it to overwrite without asking, letting the user out of this.

I can I tell it to allways assume yes, or something like that?

thanks in advance,

João
Nov 15 '07 #1
Share this Question
Share on Google+
4 Replies


KevinADC
Expert 2.5K+
P: 4,059
Hi,
I have a script that convert a file, "$novo" in this case, to a 3gp file:
this is part of the script:

Expand|Select|Wrap|Line Numbers
  1.  
  2. print "qual é o título da peça? (< 36 caracteres)\n";
  3. my $titul=<STDIN>;
  4. chomp($titul);
  5.  
  6. my $outputgprs="$titul"."_25".".3gp";    
  7.  
  8. system "ffmpeg -i '$novo' -acodec libamr_nb -ar 8000 -ac 1 -r 7 -b 25k -s 176x144 -vcodec h263 -ab 7.95k /home/user/Desktop/$outputgprs"; 
Obviously, before I already put the file to convert in "$novo". Didn't write all the code to save space.

My problem here is that sometimes already exists a file with the same name of the target file. When this happens, ffmpeg asks something like: "Do you want to overwrite the file ....?"
I'd like it to overwrite without asking, letting the user out of this.

I can I tell it to allways assume yes, or something like that?

thanks in advance,

João
The first thing I would do is see if whatever program you are using has a command line switch you can add to the system() command string to auto ovwerwrite files without asking for confirmation. If there is none, look into the Expect or Expect::Simple modules.

cpan: Expect
Nov 15 '07 #2

P: 63
you were right, there's a parameter "-y" to use in the command line to force the overwrite.

I never tought could be that simple!

thanks a lot,

João
Nov 15 '07 #3

KevinADC
Expert 2.5K+
P: 4,059
you were right, there's a parameter "-y" to use in the command line to force the overwrite.

I never tought could be that simple!

thanks a lot,

João

I've had similar situations in the past and learned to always check a programs command line switches/options for the documented commands, and also search online for any undocumented commands.
Nov 15 '07 #4

P: 4
JUST USE:

Expand|Select|Wrap|Line Numbers
  1. ffmpeg -y .....
Jul 21 '15 #5

Post your reply

Sign in to post your reply or Sign up for a free account.