You can make a difference in the Apple Support Community!

When you sign up with your Apple Account, you can provide valuable feedback to other community members by upvoting helpful replies and User Tips.

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

Batch create folder with specific names

Hello everyone! I've looked for similar issues here on Communities but still haven't found a solution for my problem.


I work as a pre-press operator and I'm a organization freak, so every time a client send me a new art file, normally a PDF one, I always create a "master" folder for that specific art, and within this folder, I create 3 other folders, one named "Output", for .AI and .PSD files, etc; one named "Client" for the client's art file that they send us; and an "Email" folder for the PDFs I create to send back to the client for approval.


I've been doing this for almost 4 years now and I always have to press SHIFT+CMD+N and type folder name for these 3 specific folders.


I was wondering if there is a way to create a shortcut for this problem (in automator or anywhere else, so that every time I press a combination of keys, these 3 folders (Output, Client and Email) show up, already named, in the Finder window that I am looking at.


I appreciate any help!

Mac Pro

Posted on Aug 4, 2020 9:59 AM

Question marked as Top-ranking reply

Posted on Aug 4, 2020 10:52 AM

The following Automator script will prompt you for the folder where you want to create the three sub-folders. It will create them if they do not already exist, and then open a new Finder window on the contents of the chosen folder. It completes in around 8 secs.



Steps:

  1. Launch Automator from your /Applications folder
    1. New Document : Desktop : Application : Choose.
  2. You will now have libraries on your left, and a larger workflow window on your right. Drag and drop the following actions in order into the right-hand workflow window:
    1. Files & Folders : Ask for Finder Items
      1. Set to image settings
    2. Utilities : Run Shell Script
      1. Set the action settings to those in the above image settings
      2. Remove any boilerplate text (e.g. for loop)
      3. Copy and paste the Code from below into the Run Shell Script window
  3. File menu : Save to your Desktop with a meaningful name
  4. Quit Automator
  5. Double-click the application on the Desktop


Code


#!/bin/zsh

typeset -ga folders=(Client Email Output)

for f in "$@"
do
	for sf in ${folders};
	do
		# make subfolders if they do not already exist, otherwise skip
		[[ -d "${f:a}/${sf}" ]] && continue
		mkdir -p "${f:a}/${sf}"
	done
	# open the current selected folder in a new Finder window
	/usr/bin/osascript -e "tell application \"Finder\" to open folder POSIX file \"$f\""
done
exit 0

Similar questions

1 reply
Question marked as Top-ranking reply

Aug 4, 2020 10:52 AM in response to Community User

The following Automator script will prompt you for the folder where you want to create the three sub-folders. It will create them if they do not already exist, and then open a new Finder window on the contents of the chosen folder. It completes in around 8 secs.



Steps:

  1. Launch Automator from your /Applications folder
    1. New Document : Desktop : Application : Choose.
  2. You will now have libraries on your left, and a larger workflow window on your right. Drag and drop the following actions in order into the right-hand workflow window:
    1. Files & Folders : Ask for Finder Items
      1. Set to image settings
    2. Utilities : Run Shell Script
      1. Set the action settings to those in the above image settings
      2. Remove any boilerplate text (e.g. for loop)
      3. Copy and paste the Code from below into the Run Shell Script window
  3. File menu : Save to your Desktop with a meaningful name
  4. Quit Automator
  5. Double-click the application on the Desktop


Code


#!/bin/zsh

typeset -ga folders=(Client Email Output)

for f in "$@"
do
	for sf in ${folders};
	do
		# make subfolders if they do not already exist, otherwise skip
		[[ -d "${f:a}/${sf}" ]] && continue
		mkdir -p "${f:a}/${sf}"
	done
	# open the current selected folder in a new Finder window
	/usr/bin/osascript -e "tell application \"Finder\" to open folder POSIX file \"$f\""
done
exit 0

Batch create folder with specific names

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