As with most things, it's about choosing the right tools for the job. You can mix-and-match which tools you use at which stage of the macro. It can be a single Execute an AppleScript
action that constitutes the entire macro (most of mine are, in fact), but you can also do one bit with AppleScript, the next bit with some proper KM "macro-ing", and a wee shell script to round it off.
Which leads me to one suggestion that eliminates a good chunk of your macro actions with a single line of shell script: since it looks like you're creating a directory tree (one folder, then a folder inside that one, then a folder inside that one), this can be done extremely easily with mkdir -p
. As an example, say you wanted to ultimately end up with a folder structure that looked like this:
%FinderInsertionLocation%/Jobs/1/Property Details/2018-06-16/Smith/
where none of these sub-folders presently exist; and inside folder Smith
, you would eventually like there to be folders called Photos
, Plans
, and Shoot
; then this is how you would do it using an Execute Shell Script
action:
f="$(</dev/stdin)" # text input = %FinderInsertionLocation%
filepath="$f/Jobs/1/Property Details/$KMVAR_date/$KMVAR_Agent_2"
mkdir -p "$filepath" # -p ensures all folders in the path are created
cd "$filepath" # Switch into the $KMVAR_Agent_2 directory,
# inside which we create...
mkdir Photos Plans Shoot # ...these three folders
If it's not implicitly evident, the name of the sub-folder of Property Details
is retrieved from a KM variable called "date"
(which I had set to 2018-06-16
), and the name of sub-folder of this is retrieved ffrom the KM variable "Agent 2"
(which I had set to Smith
).
It's 5 lines of script in total, but the one line that replaces all of those Create New Folder
actions that were giving you so much misery is mkdir -p /Path/of/Folders/To/Create
; and the second use of mkdir
then creates those three individual folders that all live inside the same directory.
Here's a schematic of the final result:
%FinderInsertionLocation%
β
βββJobs
β β
β βββ1
β β
β βββProperty Details
. β
. βββ2018-06-16
β
βββSmith
β
ββββ Photos
β
ββββ Plans
β
ββββ Shoot