Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Advertise on
Bash script problem
New on LowEndTalk? Please read our 'Community Rules' by clicking on it in the right menu!

Bash script problem

I want to encode all files in a folder from mkv to mp4. I got a bash script:

in the folder,the filename is like this :

[A-Destiny] Toriko - 51 (848x480 h264 AAC) [B7B209E9].mkv

when I execute the script, it show errors..
what can I see, when it scan the folder, the filename will be separated.example:

[A-Destiny] Toriko - 51 (848x480 h264 AAC) [B7B209E9].mkv

wll be:








the problem is, why dont it detect the filename as "[A-Destiny] Toriko - 51 (848x480 h264 AAC) [B7B209E9]"

Sorry for my bad English


  • blackblack Member
    edited October 2013

    You need to setup your $IFS variable.

    Here's an example:

    OIFS=$IFS; #save your current IFS variable
    IFS=$'\n'; #change IFS to new line char
    for file in `ls -1 test`
            echo "file -> $file";
    IFS=$OFIS; #restore your IFS variable
  • thanks :)

    Sorry for my bad English

  • hey @black, I found another solution.. just add couple quotes :)
    btw, I got another problem..

    it is successfully by doing echo..
    but, when I use it in HandBrakeCLI command, it show:

    line 11: 22384 Segmentation fault $HANDBRAKE_CLI -i "$SRC"/"$FILE" -o $DEST/$filename.$DEST_EXT

    Sorry for my bad English

  • That's probably your $HANDBRAKE_CLI or improperly passing arguments to the program.

  • for f in *.mkv; do avconv -i "$f" -codec copy "$f".mp4; done

  • I tried put "" at $DEST.. suddenly the error gone :)
    thanks all

    Sorry for my bad English

  • @awson said:
    for f in *.mkv; do avconv -i "$f" -codec copy "$f".mp4; done

    What about mkv->avi

    C, Bash, Perl, Python, PHP, and JS hobbyist. VPS collector. Blog

  • @joelgm said:
    What about mkv->avi

Sign In or Register to comment.