Changing File Names (extensions)

Get help. Get answers. Let others lend you a hand.

Moderator: Mr_Noodle

Changing File Names (extensions) Sat Sep 26, 2015 12:29 pm • by sailingbikeruk
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

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?
sailingbikeruk
 
Posts: 5
Joined: Sat Sep 26, 2015 12:16 pm

Re: Changing File Names (extensions) Mon Sep 28, 2015 12:01 pm • by Mr_Noodle
I think it is more of a general bash scripting question. One alternate thing to try is the 'basename' command to strip off the extension.
Mr_Noodle
Site Admin
 
Posts: 11868
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City


Return to Support