Howdy, Stranger!

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


Shells Virtual Desktop
BMail.ag - Secure Email Service
Server.net
CPLicense.net
VPS Server
Buy VPN
Vultr
VMs for AI
HostDare
ReliableSite White-Label Dedicated Hosting for Resellers
InterServer VPS
BMail.ag - Secure Email Service
Best VPN
High-Performance Bare Metal Server Solutions
Karvl.com
Server Mania Cloud Hosting
DataWagon Hosting
AlphaVPS Hosting
Evoxt.com
Clouvider
VPS Hosting with NVMe
Residential IPs in the US & 4G Mobile Proxies in EU & US with Unlimited Bandwidth
ReliableSite White-Label Dedicated Hosting for Resellers
Rabisu - Hosting Solutions
Shells Virtual Desktop
New on LowEndTalk? Please Register and read our Community Rules.

All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.

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:

[A-Destiny]

Toriko

51

848x480

h264

AAC

[B7B209E9]

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

Comments

  • blackblack Member
    edited October 2013

    You need to setup your $IFS variable.

    Here's an example:

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

  • 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

  • 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

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

    What about mkv->avi

  • @joelgm said:
    What about mkv->avi

    https://libav.org/avconv.html

Sign In or Register to comment.