469,326 Members | 1,415 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,326 developers. It's quick & easy.

overwrite file without asking

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
4 34624
KevinADC
4,059 Expert 2GB
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
jcor
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
4,059 Expert 2GB
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
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.

Similar topics

1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by harlem98 | last post: by
reply views Thread by listenups61195 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.