So Many Tools but which one to choose

automator
#1

So many tools, Automator, Alfred, Keyboard Maestro, AppleScript, Hazel but can’t seem to find one which will easily allow me to perform the following simple task. Create 12 Folders 01 Jan, 02 Feb, 03 Mar… Etc thru 12 Dec. I file records monthly and each year I set up a new folder, “2019” and want to create the 12 folders described above in the 2019 folder. I do this multiple times each year so it becomes tedious, a perfect automation opportunity, or so it would seem. It seems neither KM or Automator allow you to “get” the current file path which is required to create the new folders. Saw several examples of calling AppleScript to get the file path but I can’t believe it is THAT difficult.

What am I missing???

Tim

0 Likes

#2

If you’re using Hazel to file the documents it can sort into a sub folder - and if that sub folder doesn’t exist it will create it for you.

Keyboard Maestro can also create folders.

3 Likes

#3

This is the sort of things that’s been done with automation scripts since scripting was introduced. The issue I think you have is that you are coming at it from a very high end, end user interaction perspective but this is acting down at the file system level. That’s a broad generalisation, but this is why you might need to use something that gets down to that lower level.

With a shell script it can be as easy as this; for an example project in a Projects folder on ypur home directory.

#!/bin/bash
cd ~/Projects/Project_1_2019/
mkdir "Jan 01" "Feb 02" "Mar 03" "Apr 04" "May 05" "Jun 06" "Jul 07" "Aug 08" "Sep 09" "Oct 10" "Nov 11" "Dec 12"

The issue is passing to the script where you want this to occur if you are not already futzing around in the terminal. But this post might help with that.

Here Automator is passing information to a scipt to tell the script where it is and where to run. The other tools have their own ways of passing information around.

So what to use? Well, that’s simply personal preference based on your own workflows and how you prefer to use your device. If you used this a lot I’d suggest tying it into a hotkey or if you tag a file name with something and it existed under a watched Hazel branch you could have Hazel automatically rename and build the folder structure for you.

I’d personally look to have something that I trigger, asks me for the parent folder name, creates that, and then at the same time creates the month folders.

Hope that helps.

0 Likes

#4

How are you wanting to initiate the automation? You said KM won’t allow you to “get” the current file path, so will you have a folder “2019” selected in finder?

0 Likes

#5

I used to use this regularly when creating flat file CMS templates in Statamic

Planter

Basically it creates a series of folders and nested folders from a simple text file.

This is an ideal way of setting up often used directory structures from a simple terminal command.

0 Likes

#6

Here’s an example of ApplesScript to call mkdir

https://github.com/derickfay/course-creator/blob/master/Generate%20directories.applescript

0 Likes

#7

Many thanks to everyone who has responded to this post it is great to see such an active community… Your suggestions have given me a number of good ideas which to explore further. :grinning:

0 Likes

#8

Hello, yes my original thought was to simply have the target folder where I wanted the sub folders created and run the KM Macro which would simply run 12 “Create New Folder” commands. Unfortunately it seems this command requires a fully qualified pathname as input, not simply the “new folder”

0 Likes

#9

If you’re starting from Finder, you can use KM “For Each…in these collections” where the collection is “The Finder’s Selection” to assign the selected file to a KM variable. The Get File Attribute then gives you access to all sorts of stuff like the parent path, name, tags, type, and more.

If I understand what you’re after, I think it is doable natively in KM.

1 Like

#10

Thanks, this gave me the steer I needed. In the end it was far simpler than I expected, I prompted for the parent of the new folders and then had 12 “Create New Folders” using the path returned from the prompt to prefix the folder name.

Thanks,
Tim

0 Likes

Feature request: "play" button to execute script (in overview)
#11

Sweet! Glad it helped.

0 Likes