I'm a graphic designer and need an organized folder scaffold for all of my projects. I have a work flow now that:

  • asks for the project name
  • asks where the project folder needs to be stored
  • then creates the sub folders that I will be using.

Such as a folder named "Project 1" then inside are the sub folders named "images", "Photoshop", "drafts", "Illustrator" and so on.

Scaffoldenter image description here

I am trying to create a folder action that sorts files that are added to the project root folder into the an appropriate sub folder, either by file extension or by part fo the file names.

For example:

  • .jpg files shoudl be moved to the image folder
  • .psd files should be moved to the Photoshop folder
  • file names that contain the word "draft" should be moved to the drafts folder.

What I've tried so far is to make a folder action that does this but it sends those files to the folder originally writen in the folder action. If I make a folder action that sends .psd files to the Photoshop folder into "Project 1", then that action to the next folder "Project 2" will still send those files to the Photoshop folder in "Project 1", instead of in "Project 2".

Any suggestions on how to do this?


Here is a way to go about achieving the goal. (It is not the only way to achieve the goal.)

First I'd make a placeholder template Folder Action using Automator and after creating it, disable it in Folder Action Setup, but leave the workflow available where it gets saved. This will be opened at the end of creating a new project folder to then be assigned to it and saved as its name, thus leaving the placeholder template Folder Action available for the next new project folder.

The images of the two workflows are placed at the bottom so as to make the answer easier to read.

You will need to add to the example shell script code, as all of the conditions were not expressed in your question.



Placeholder template Folder Action

Example shell script code:

#!/bin/bash

    # f = fully qualified pathname
    # d = directory pathname
    # fn = filename with extension
    # n = filename without extension
    # e = filename extension

shopt -s nocasematch

for f in "$@"; do

    d="${f%/*}"
    fn="${f##*/}"
    # n="${fn%.*}"
    e="${fn##*.}"

    cd "${d}" || exit
    [ -w "${d}" ] || exit

    [[ ${e} == jpg ]] && mv -n "${f}" './Images/'
    [[ ${e} == psd ]] && mv -n "${f}" './Photoshop/'
    [[ ${fn} =~ draft ]] && mv -n "${f}" './Drafts/'

    [ -f "${f}" ] && mkdir -p 'Other'; mv -n "${f}" './Other/'

 done

Note: The last test before done handles any case not already defined. Obviously you can choose not to use it and remove it from the example shell script code.



Create New Project Folder Structure

For an Automator workflow to create the new project folder, use the screenshot of the following workflow:

The example shell script code of the Run Shell Script action is:

mkdir "$1/$2" || exit
cd "$1/$2" || exit
mkdir 'After Effects' 'Assets' 'Audition' 'Drafts' 'Excel' 'Final' 'Fonts' 'Illustrator' 'Images' 'Photoshop' 'Premier' 'Word'

open "${HOME}/Library/Workflows/Applications/Folder Actions/Foobar.workflow"

Note: Change the name of the Folder Action workflow in the example shell script code from Foobar.workflow to whatever its actual name is.

Also note in the image below of the Create New Project Folder Structure workflow how there are logical breaks between some of the actions and in the end the value of the two variables are separate from the rest of the workflow. While the workflow shown in the question works, nonetheless, in my opinion this is a better way of doing it as it breaks the workflow into logical action blocks, which makes it easier to follow/understand what the workflow is doing.

Technically the Create New Project Folder Structure workflow only needs one variable and it could be structured as, e.g:

  • Ask For Text action
  • set Value of Variable action
    • Variable: [New Project]
  • Ask for Finder Items action
    • [Optons] [√] Ignore this action's input
  • Get Value of Variable action
    • Variable: [New Project]
  • Run Shell Script action

While this does work and has less actions than what's show in the question, nonetheless, as I mentioned earlier about logical action blocks within the workflow which makes it easier to follow/understand what the workflow is doing.



Folder Action Setup

Folder Action Setup can be used to work with as needed any Folder Action created.

Folder Action Setup can be opened using Spotlight by pressing ⌘ Space and start typing its name, then once selected, press Enter.



enter image description here


enter image description here