Anyone want to be more specfic about writing shell scripts?

Talk, speculate, discuss, pontificate. As long as it pertains to Hazel.

Moderators: Mr_Noodle, Moderators

I was delighted with the help descriptions of how to use Hazel to run an Applescript on each file in a folder. However, I'm confused by using a shell script for the same purpose. Admittedly, this might be due to my own inexperience with shell scripting as I've only dabbled up till now.

In the AS, you use infile as the place holder for the file that Hazel will feed in the applescript. What serves that function for a shell script? Here's the real command I need to run.

Code: Select all
qt_export --exporter=mpg4,appl --loadsettings=exportsettings.dat HAZEL_FILE_GOES_HERE /videos/resultingfile.mp4


So when I write the shell script, what should actually go in the place of HAZEL_FILE_GOES_HERE ?
grovberg
 
Posts: 17
Joined: Thu Nov 30, 2006 3:44 pm

Thu Dec 14, 2006 6:24 pm • by Mr_Noodle
Since shell scripts can be written in a variety of languages, it depends on the language in terms of accessing arguments.

I'll use 'sh' for this example:

Code: Select all
#!/bin/sh

qt_export --exporter=mpg4,appl --loadsettings=exportsettings.dat $1 /videos/resultingfile.mp4


The first line tells the shell to use 'sh' to interpret the script. In 'sh', $1 refers to the first argument, which in the case of Hazel, will be the name of the file. $0 refers to the script itself, FYI.

I recommend looking online for a shell scripting tutorial. 'sh' is commonly known as the 'bourne shell' in case you wanted something to search on.
Mr_Noodle
Site Admin
 
Posts: 11195
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City


Return to Open Discussion