Page 1 of 1

How to use the output of a shell script in a Rename action

PostPosted: Wed Jul 17, 2024 9:27 am
by halloleo
I have a shell script which - based on the given file - returns/outputs a new file name.

How can I use that output in the Rename action?

Re: How to use the output of a shell script in a Rename acti

PostPosted: Thu Jul 18, 2024 9:26 am
by Mr_Noodle
You can't do it from a shell script. You would either need to (a) use an AppleScript and specify the new target in the return record or (b) have a separate rule to match the output file.

Re: How to use the output of a shell script in a Rename acti

PostPosted: Thu Jul 18, 2024 9:41 am
by halloleo
Mr_Noodle wrote:You can't do it from a shell script. You would either need to (a) use an AppleScript and specify the new target in the return record


So an Applescript can tell Hazel a match variable which Hazel then can use in its Rename Action. Hiw can an Applescrdo this?

Mr_Noodle wrote:(b) have a separate rule to match the output file.


I don't understand this one: How can a seperate rule do the Renaming do better than the first one?

Maybe I wasn't clear enough: My Shell- or Applescript does return a file name (string). It does not rename the file. I want to leave the renaming to Hazel.

Re: How to use the output of a shell script in a Rename acti

PostPosted: Fri Jul 19, 2024 8:32 am
by Mr_Noodle
Ok, that's a bit different. You would still need to use AppleScript to export that as a custom attribute which you can then access in a subsequent Rename action.

Re: How to use the output of a shell script in a Rename acti

PostPosted: Fri Jul 19, 2024 9:11 am
by halloleo
Mr_Noodle wrote:Ok, that's a bit different. You would still need to use AppleScript to export that as a custom attribute which you can then access in a subsequent Rename action.


I see. Thanks. I found https://www.noodlesoft.com/manual/hazel ... Attributes. That might get me there I guess.

Re: How to use the output of a shell script in a Rename acti

PostPosted: Fri Jul 19, 2024 8:59 pm
by halloleo
Got it working. Thanks for your help. :D