Changing File Names (extensions)

I am new(ish) to MAC but an experienced windows IT Manager, I can't figure this out and I suspect this is a shell question rather than a Hazel question so I'll go elsewhere if that is the case, but as it started in a Hazel Forum and I am using Hazel to launch HandbrakeCLI I thought I'd ask here.
I took a shell script form this post http://www.noodlesoft.com/forums/viewtopic.php?p=3447 the text of which was
I amended it to read:
Handbrake runs just fine and does the encode as expected, however, I was expecting that it would remove the .mkv from the filename and add .m4v instead. It isn't doing this though, it is just appending .m4v to the end of the filename
What am I missing? Is there a simpler way to rename a file with Hazel after handbrake has encoded it?
I took a shell script form this post http://www.noodlesoft.com/forums/viewtopic.php?p=3447 the text of which was
- Code: Select all
/Applications/HandbrakeCLI -i "$1" -o "${1%avi}"mp4 --preset='iPhone & iPod Touch'
I amended it to read:
- Code: Select all
/Applications/HandbrakeCLI -i "$1" -o "${1%.mkv}.m4v" --preset="Universal" -v
Handbrake runs just fine and does the encode as expected, however, I was expecting that it would remove the .mkv from the filename and add .m4v instead. It isn't doing this though, it is just appending .m4v to the end of the filename
What am I missing? Is there a simpler way to rename a file with Hazel after handbrake has encoded it?