overwrite file without asking

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jcor
    New Member
    • Sep 2007
    • 63

    #1

    overwrite file without asking

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

    Code:
    print "qual é o título da peça? (< 36 caracteres)\n";
    my $titul=<STDIN>;
    chomp($titul);
    	
    my $outputgprs="$titul"."_25".".3gp";	
    
    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
  • KevinADC
    Recognized Expert Specialist
    • Jan 2007
    • 4092

    #2
    Originally posted by jcor
    Hi,
    I have a script that convert a file, "$novo" in this case, to a 3gp file:
    this is part of the script:

    Code:
    print "qual é o título da peça? (< 36 caracteres)\n";
    my $titul=<STDIN>;
    chomp($titul);
    	
    my $outputgprs="$titul"."_25".".3gp";	
    
    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

    Comment

    • jcor
      New Member
      • Sep 2007
      • 63

      #3
      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

      Comment

      • KevinADC
        Recognized Expert Specialist
        • Jan 2007
        • 4092

        #4
        Originally posted by jcor
        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.

        Comment

        • tazosmr
          New Member
          • Feb 2012
          • 4

          #5
          JUST USE:

          Code:
          ffmpeg -y .....

          Comment

          Working...