trouble with name increment

Discussion in 'Command Line' started by jaaf, Jan 15, 2012.

  1. jaaf

    jaaf New Member

    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    Hi,
    I am trying to write a script that records a window on my screen. No pb with that.
    To go further I would like to choose an incremental fileName for output incrementing if the fileName already exist.
    I have trouble doing it so before dealing with the incrementation itself, I want to check I can substitute the calculated name in the ffmpeg command.

    Code:
    filename="~/Bureau/essai" 
    
    index=1 #I[B] will deal with the incrementation of index after this part works [/B]
    
    mystring="${fileName}${index}.mkv" #omce I have a proper index I concatenate the name with index and name extension 
    
    echo ${mystring} # gives ~/Bureau/essai1.mkv seems to be what I expect 
    
    ffmpeg -f alsa .....  -y ${mystring}  # gives error message ~/Bureau/essai1.mkv: No such file or directory despite -y to force overwriting
    I get this message


    However if I put the file name directly in the command like this


    Code:

    Code:
    ffmpeg -f alsa .....  -y ~/Bureau/essai1.mkv
    it works perfectly. My question is : "What is wrong ?"
  2. KenJackson

    KenJackson Active Member

    Messages:
    129
    Likes Received:
    28
    Trophy Points:
    28
    Do you have a subdirectory in your home directory named Bureau?

    If not, then that's the problem. Execute mkdir Bureau and then run the script again.
  3. jaaf

    jaaf New Member

    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    Thanks for your answer.

    Bureau is the French translation for Desktop and I*can CD to it from terminal. Moreover if the string
    Code:
     ffmpeg  -f alsa .....  -y ~/Bureau/essai1.mkv
    is written directly in the scipt it works fine.

Share This Page