How do I create a folder structure based on Order No?

This is what I’ve worked out so far with some help from some folks on Apple’s discussion forum. Redirecting the question here as it might gain a little more exposure. This is to be a 2-part task with hopes of building up more automation into it as time goes on.

GOAL #1
The first goal is to have an operator enter info into dialog prompt which includes an order number and last name, i.e. 123 Johnson. Using that information, a folder structure will be generated with all the necessary nested folders. In the first example below I working on getting this to happen through an Automator workflow, but it’s not creating all the nested folders. The final structure should look like this:

123 Johnson
…123 Johnson PDFs
…123 Johnson Print Ready
…123 Johnson Proof Only
…123 Johnson Photos
…123 Johnson Touch Ups
…123 Johnson Originals
…123 Johnson Products
…123 Johnson Tri-Fold
…123 Johnson Thank You Card
…123 Johnson Prayer Card
…123 Johnson Portrait
…123 Johnson Memorial Folder
…123 Johnson DVD
…123 Johnson 8pg Memorial Booklet
…123 Johnson Theme


on run {input, parameters}
	set fol_ders to input
	set new_sub_list to {{"_Photos", {" Touch Ups", " Originals"}}, {" Products", {" Tri-Fold", " Thank You Card", " Prayer Card", " Portrait", " Memorial Folder", "_DVD", " 8pg Memorial Booklet"}}, {" Theme"}, {" PDFs", {" Print Ready", " Proof Only"}}}
	tell application "Finder"
		repeat with a in fol_ders
			set a_name to a's name
			repeat with nf in new_sub_list
				set fold01 to make new folder in a with properties {name:(a_name & (nf's item 1))}
				repeat with nnf in (nf's item 2)
					set aa_name to fold01's name
					-- if I want to include the parents folder's name in the nested folder's name
					-- make new folder in fold01 with properties {name:(aa_name & nnf)}
					make new folder in fold01 with properties {name:(a_name & nnf)}
				end repeat
			end repeat
		end repeat
	end tell
end run

GOAL #2
The second goal is to pull files from a standard location on the local machine / network and drop the necessary support files into the appropriate nested folders. An order will come in with with a list of selected template items a.k.a theme, i.e. indesign layouts, copy, music. Lets say there are 20 different themes. Based on user input it will grab a copy of the appropriate elements from that theme. Can a dialog prompt be presented at the same time the information for the order number is entered? For example, asking for which elements from selected pop-ups?

I’m starting to realize, with the complexity involved, there is probably going to required a wrapping UI :frowning:
I was just hoping to be sent in the right direction.

AN ALTERNATIVE
The user can drag a copy of a theme, comprised of nested folders, each containing the templates and support files. Followed by a recursive renaming of all the elements to match the order number. I’m thinking I could ensure that all folders/files to be renamed have the same prefix, i.e. Theme A. The default folder structure of a theme would look similar to this with the desired changes in brackets:

Theme A (123 Johnson)
Theme A 8pg Memorial Booklet (123 Johnson 8pg Memorial Booklet)
Theme A 8pg Memorial Booklet.indd (123 Johnson 8pg Memorial Booklet.indd)
…Pictures
Theme A 1-2.psd (123 Johnson 1-2.psd)
Theme A 3-4.psd (123 Johnson 4-5.psd)
Theme A 5-6.psd (123 Johnson 6-7.psd)
Theme A 7-8.psd (123 Johnson 7-8.psd)
Theme A 8pg Memorial Booklet Master.psd (123 Johnson 8pg Memorial Booklet Master.psd)
Theme A DVD (123 Johnson DVD)
…Pictures
…DVD Image Template.psd
…Label
Theme A DVD Label.ai (123 Johnson DVD Label.ai)
Theme A DVD Label.psd (123 Johnson DVD Label.psd)
…LC Menu.jpg
Theme A DVD Memory.ai (123 Johnson DVD Memory.ai)
Theme A DVD Remembering.ai (123 Johnson DVD Remembering.ai)
Theme A DVD Title Screen.psd (123 Johnson DVD Title Screen.psd)
Theme A Memorial Folder (123 Johnson Memorial Folder)
Theme A Memorial Folder.indd (123 Johnson Memorial Folder.indd)
…Pictures
Theme A Cover.psd (123 Johnson Cover.psd)
Theme A Portrait (123 Johnson Portrait)
…Pictures
Theme A Portrait.psd (123 Johnson Portrait.psd)
Theme A Prayer Card (123 Johnson Prayer Card)
Theme A Prayer Card.indd (123 Johnson Prayer Card.indd)
…Pictures
Theme A Prayer Card Back.psd (123 Johnson Prayer Card Back.psd)
Theme A Prayer Card Front.psd (123 Johnson Prayer Card Front.psd)
Theme A Thank You Card (123 Johnson Thank You Card)
Theme A Thank You Card.indd (123 Johnson Thank You Card.indd)
…Pictures
Theme A Thank You Card Cover.psd (123 Johnson Thank You Card Cover.psd)
Theme A Tri-Fold (123 Johnson Tri-Fold)
Theme A Tri-Fold.indd (123 Johnson Tri-Fold.indd)
…Pictures
Theme A Inside.psd (123 Johnson Inside.indd)
Theme A Outside.psd (123 Johnson Outside.indd)

Any help would be amazingly appreciated!

Re: GOAL 1

What is actually happening? I’m not a big fan of automator, my own ignorance I know, but making a script version to work wasn’t much different from what you had posted.

set orderNum to text returned of (display dialog "Please enter a order number" default answer "")
set lastName to text returned of (display dialog "Please enter the last name" default answer "")
set orderName to orderNum & space & lastName
set new_sub_list to {{"Photos", {" Touch Ups", " Originals"}}, {" Products", {" Tri-Fold", " Thank You Card", " Prayer Card", " Portrait", " Memorial Folder", "_DVD", " 8pg Memorial Booklet"}}, {" Theme"}, {" PDFs", {" Print Ready", " Proof Only"}}}
tell application "Finder"
	set baseFolder to make new folder at desktop with properties {name:orderName}
	repeat with i from 1 to count new_sub_list
		try
			set {tier2, t2Subs} to {item 1, item 2's items} of item i of new_sub_list
			set tier2Folder to make new folder at baseFolder with properties {name:tier2}
			repeat with tier3 in t2Subs
				make new folder at tier2Folder with properties {name:tier3}
			end repeat
		on error
			make new folder at baseFolder with properties {name:(item 1 of item i of new_sub_list)}
		end try
	end repeat
end tell

set orderNum to text returned of (display dialog "Please enter a order number" default answer "")
set lastName to text returned of (display dialog "Please enter the last name" default answer "")
set orderName to orderNum & space & lastName
set new_sub_list to {{" Photos", {" Touch Ups", " Originals"}}, {" Products", {" Tri-Fold", " Thank You Card", " Prayer Card", " Portrait", " Memorial Folder", " DVD", " 8pg Memorial Booklet"}}, {" Theme"}, {" PDFs", {" Print Ready", " Proof Only"}}}
tell application "Finder"
	set baseFolder to make new folder at desktop with properties {name:orderName}
	repeat with i from 1 to count new_sub_list
		try
			set {tier2, t2Subs} to {item 1, item 2's items} of item i of new_sub_list
			set tier2Folder to make new folder at baseFolder with properties {name:(orderName & tier2)}
			repeat with tier3 in t2Subs
				make new folder at tier2Folder with properties {name:(orderName & tier3)}
			end repeat
		on error
			make new folder at baseFolder with properties {name:(orderName & (item 1 of item i of new_sub_list))}
		end try
	end repeat
end tell

That almost takes cares of the initial component. I made a slight chang by adding orderName as a prefix to the nested folders as well. Plugging away…

Any thoughts on the Alternative solution of doing a find-replace on the pre-built folders of files and folders? It could save time of having the user needing to move all the support files into the proper nested folders manually…

Hey KC, the alternative should be very easy to do… Do you have a template directory you can zip up and provide for me to do some full testing with? Shoot me an email through the forum.

This is the craziest thing. I logged in earlier today without issue, not really remembering my login info from years back. I was kind of surprised to say the least. Anyhow when you asked me to upload a snapshot of the directory it informed me that I was NOT logged in. I tried again, but it failed. I tried having my password sent to me, but it wouldn’t take any of my e-mail addresses. It was then that I noticed the CRAZIEST thing.

Looking at my original post and replies it lists me as TRASH MAN with almost 5000 posts!! What the heck. It seems that something got messed up in the user database for the forum. Anyhow, I’ve zipped the directory structure and included placeholders for the default documents and folders (created an empty text file and changed it’s extension accordingly). I placed them where they need to be within the folder hierarchy.

I guess I’m just waiting on your email. Thanks again for your help!

About 3 years ago now, the bbs underwent a massive restructuring (not in appearance, but behind the scenes). At that time, an effort was made to identify all the members whose status was iffy, and when no response was received, they were cleaned out. Not wanting to trash their posts, however, we simply designated them as Trash Man. Yours must have been among those. No offense intended, and none taken I hope – glad to have you back in the fold.

And here I thought Trash Man was an actual user here… Perhaps thats because I know an actual “Trash Man” on another forum LOL

That makes for an interesting explanation. Interesting…

kc, you have mail!

Wow, this is great! I haven’t touched Applescript in over 6 years. I’m really really rusty. Even at my best I was just a tinkerer.

It looks like the script is assuming the name of the theme. I used “Theme_A” as an example but the actual themes don’t comply to much of a convention. I noticed the charCount section of the script might be the culprit. It seems to have broken when I took a resulting, successfully renamed folder structure, CPIO’s it, and then used it as a theme source.

If it’s not too much trouble, would you be able to generate a droplet for the CPIO function? I could go ahead and do all the themes myself, but when I’m not around I’m sure someone will want to tackle it themselves.

Eventually I would love to be able to take the values from another source, i.e. Filemaker, and use it for the input values of the orderNum and lastName values at the prompt, as well as the theTheme to be used.

I’m going to have to find a way to repay you for this work…

Well, at least my early attempts to assist you on the Apple Discussions board were not completely in vain…