Apple Event: May 7th at 7 am PT

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Automator script tweak

Hello,


I discovered this neat little script that was kindly posted a while ago (Use Automator/AppleScript to create multi… - Apple Community)

It would be pretty useful if I could add one more thing.

With each of the sub-folders created could there be an opportunity to add a prefix label to each sub-folder that is a shortened name of the project?


ie Project folder is SuperDry5 and each sub-folder adds SD5 before it's main name


Any help much appreciated.


Alastair


iMac 27″ 5K, macOS 10.14

Posted on Apr 9, 2022 8:39 AM

Reply
Question marked as Best reply

Posted on Apr 11, 2022 9:37 AM

Here is the original workflow from the preceding linked post with modifications:




And the working part of the Run Shell Script that you can copy/paste back into your blank Run Shell Script action. Take special care when editing the folder hierarchy names and punctuation, as typos have caused many a workflow to bork:


# remove all lowercase text from project folder name leaving capital letters and numbers

TLA="${2//[a-z]/}"

# one mkdir execution with multiple folder hierarchy

/bin/mkdir -p "$1/$2" \
"$1/$2/${TLA}_Media-Source" \
"$1/$2/${TLA}_Media-Generated" \
"$1/$2/${TLA}_Music" \
"$1/$2/${TLA}_Music/${TLA}_Temp" \
"$1/$2/${TLA}_GFX" \
 "$1/$2/${TLA}_Outputs" \
"$1/$2/${TLA}_Outputs/${TLA}_Final Deliverables" \
"$1/$2/${TLA}_Outputs/${TLA}_Final Deliverables/${TLA}_ProRes" \
 "$1/$2/${TLA}_Outputs/${TLA}_Final Deliverables/${TLA}_1080p Web"


Tested on macOS 11.6.5 on an M1 mini.

10 replies
Question marked as Best reply

Apr 11, 2022 9:37 AM in response to Alastair King

Here is the original workflow from the preceding linked post with modifications:




And the working part of the Run Shell Script that you can copy/paste back into your blank Run Shell Script action. Take special care when editing the folder hierarchy names and punctuation, as typos have caused many a workflow to bork:


# remove all lowercase text from project folder name leaving capital letters and numbers

TLA="${2//[a-z]/}"

# one mkdir execution with multiple folder hierarchy

/bin/mkdir -p "$1/$2" \
"$1/$2/${TLA}_Media-Source" \
"$1/$2/${TLA}_Media-Generated" \
"$1/$2/${TLA}_Music" \
"$1/$2/${TLA}_Music/${TLA}_Temp" \
"$1/$2/${TLA}_GFX" \
 "$1/$2/${TLA}_Outputs" \
"$1/$2/${TLA}_Outputs/${TLA}_Final Deliverables" \
"$1/$2/${TLA}_Outputs/${TLA}_Final Deliverables/${TLA}_ProRes" \
 "$1/$2/${TLA}_Outputs/${TLA}_Final Deliverables/${TLA}_1080p Web"


Tested on macOS 11.6.5 on an M1 mini.

Apr 10, 2022 9:03 AM in response to Alastair King

Hi Alastair King,

To add a script to your workflow, follow these steps: "Click Actions in the top-left corner of the Automator window, then select Utilities in the Library.Drag the Run AppleScript action into your workflow.You can edit, compile, and test your script right in the action, or you can develop your script in Script Editor."More details can be found in this article: Add AppleScript scripts to a workflow in Automator on Mac

If what you're trying to do is not an option, we welcome your feedback here: Product Feedback

Cheers!

Apr 10, 2022 11:14 AM in response to Alastair King

I was waiting to see if TonyT1 would come along and add the requested enhancement. Perhaps you can do it yourself, if the goal is to just remove all lowercase letters from a variable, leaving capitals and numbers.


The following will work in the Bash or Zsh shell:

x="SuperDry5"
y="${x//[[:lower:]]/}"
SD5
z="${y}-${x}"
SD5-SuperDry5



Apr 10, 2022 12:32 PM in response to VikingOSX

Thanks, VikingOSX.


Unfortunately I really don't understand how to apply this to the script that I wanted to adapt. I've never used Automator before and am piggy-backing on the pre-existing script Tony T1 created.


I'm not even sure I have explained what I'm trying to achieve well enough either.


The original script linked adds category sub-folders to a project folder (which we'll call SuperDry5). My hope is that with all of the sub-folders it creates there would also be an opportunity at add a prefix (SD5) to the name of the sub-folders each time it runs the routine.


So if after completing SuperDry5 my next project is ExtraDamp7 then running the routine again would provide a set of ExtraDamp7 project folders with the prompt to add ED7 to the start of each sub-folder name.


Hope that makes it clearer.


Alastair

Automator script tweak

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.