Page 1 of 1

embedding AppleScript for renaming subfolders

PostPosted: Thu Apr 06, 2023 7:27 pm
by rtrumbower
I am looking for a solution to the following problem:

filename on desktop is "Word1 Word2 Word3.txt"

I hope to use an embedded Applescript to create a subfolder with a name corresponding to the second word (i.e., Word2) of the original filename. Is this possible?

My initial thought is:
1. add a line to the Hazel rule to "Run AppleScript"
2. Specify the custom attributes imported (Name) and exported (subfolderName) by the embedded AppleScript.
3. set CurrentName to item 1 of inputAttributes
4. set folderName to second word of CurrentName
5. return {hazelOutputAttributes:{subfolderName}}
6. add a line to the Hazel rule to "Sort into subfolder" with the custom pattern "subfolderName"

I know there are steps missing here but not sure how to move forward with this automation.

Re: embedding AppleScript for renaming subfolders

PostPosted: Fri Apr 07, 2023 9:30 am
by Mr_Noodle
I believe you emailed in about this. Please only post or email to one place and not both. I replied to you there but in short, lok up "match patterns" in the manual.