Page 1 of 1

Need Help with Shell Script

PostPosted: Fri May 05, 2017 7:26 pm
by jordanwade33
I need some help with a shell script. I'm trying to get Hazel to trigger Compressor to automatically convert image sequences to quicktime videos. I know how to use Compressor's Command Line functions, but Im having trouble getting a shell script from Hazel to feed into it. Basically, I only need two parameters for Hazel to feed the shell script. This is the shell script that will run successfully from Terminal.

/Applications/Compressor.app/Contents/MacOS/Compressor -computergroup "This Computer" -jobpath ~/Desktop/Hazel\ Watch\ Folder/VideoFolderToConvert/ -settingpath ~/Library/Application\ Support/Compressor/Settings/ProRes_4444.cmprstng -locationpath ~/Desktop/Hazel\ Watch\ Folder/VideoFolderToConvert.mov

So I need Hazel to fill the jobpath and locationpath. Jobpath is the folder that triggers Hazel to run when it gets added to the watch folder, so that should just be $1, right? The locationpath needs to turn the jobpath folder name into foldername.mov.

Hopefully that all makes sense. I think it should be something easy for someone good at shell scripting, but I'm just learning. Thanks for your help.

Re: Need Help with Shell Script

PostPosted: Mon May 08, 2017 10:50 am
by Mr_Noodle
Yes, "$1" (don't forget to put double-quotes around it) has the full path from which you should derive the rest.

Re: Need Help with Shell Script

PostPosted: Mon May 08, 2017 10:57 am
by jordanwade33
Thank you for the quick response. Please forgive my ignorance as I'm new to shell scripting. How would I use "$1" to derive the second variable which is the parent folder of "$1" + "/" + name of "$1" + ".mov"?

Re: Need Help with Shell Script

PostPosted: Mon May 08, 2017 11:46 am
by Mr_Noodle
Look up "dirname". That will give you the directory name. From there, you can combine that with the rest to form a new pathname.

Re: Need Help with Shell Script

PostPosted: Mon May 08, 2017 11:54 am
by jordanwade33
Thanks for your help!