Jump to content

shell scripting question


ottsk
 Share

2 posts in this topic

Recommended Posts

I'm using a couple of scripts to process video files using Handbrake CLI. The first script is converts the video to a mp4 file, the second script fixes the file extension. I run the seperately. From the shell I type:

 

for I in *;

do /opt/local/bin/HandbrakeCLI -i "$I" -o "${I}d" --preset="AppleTV"

done

 

Once the queue has been run, I run a quick script to add the correct file extension:

 

for I in *d;

do mv "$I" "${I%.*d}.m4v";

done

 

I have two questions. First, I've had trouble putting these into a single shell script. The second question is how can I setup a script that I run in the background that will process the queue everytime a new file is added to the directory.

 

If you have any suggestions, that would be great!

 

Thanks!

-S

Link to comment
Share on other sites

  • 3 weeks later...

Well I dont use much shell script, rather work with perl.

To automate, what you can do is make the shell script run on your crontab like every 10 mins, it scans the directory and takes action if needed (can be triggered by extension).

 

If you do this by crontab it will run on the background, if you do it by hand, add && in the end. I would though recommend to direct the output to a file (used as log in case something goes wrong).

Link to comment
Share on other sites

 Share

×
×
  • Create New...