Help needed with creating directory structure

Is there a way to shorten this script? It creates a few maps.


tell app "Finder"
set dc240hotfoldersMap to make new folder at "Macintosh HD:Users:Shared" with properties {name:"DC240_HotFolder"}
		set A4Map to make new folder at dc240hotfoldersMap with properties {name:"A4"}
		
		set colorMap to make new folder at A4Map with properties {name:"Color"}
		make new folder at colorMap with properties {name:"Booklet"}
		make new folder at colorMap with properties {name:"Duplex"}
		make new folder at colorMap with properties {name:"Single"}
		
		set grayMap to make new folder at A4Map with properties {name:"B/W"}
		make new folder at grayMap with properties {name:"Booklet"}
		make new folder at grayMap with properties {name:"Duplex"}
		make new folder at grayMap with properties {name:"Single"}
		
		
		set A3Map to make new folder at dc240hotfoldersMap with properties {name:"A3"}
		
		set colorMap to make new folder at A3Map with properties {name:"Color"}
		make new folder at colorMap with properties {name:"Booklet"}
		make new folder at colorMap with properties {name:"Duplex"}
		make new folder at colorMap with properties {name:"Single"}
		
		set grayMap to make new folder at A3Map with properties {name:"B/W"}
		make new folder at grayMap with properties {name:"Booklet"}
		make new folder at grayMap with properties {name:"Duplex"}
		make new folder at grayMap with properties {name:"Single"}
end tell

One more thing, is it possible that when you’re running a script and you type a specific word, the script displays you a dialog box (a little easter egg).

Hi,

try this


property dc240hotfoldersMap : missing value

tell application "Finder" to set dc240hotfoldersMap to make new folder at (path to shared documents) with properties {name:"DC240_HotFolder"}
make_subfolders("A4")
make_subfolders("A3")


on make_subfolders(N)
	tell application "Finder"
		set subfolder to make new folder at dc240hotfoldersMap with properties {name:N}
		
		set colorMap to make new folder at subfolder with properties {name:"Color"}
		make new folder at colorMap with properties {name:"Booklet"}
		make new folder at colorMap with properties {name:"Duplex"}
		make new folder at colorMap with properties {name:"Single"}
		
		set grayMap to make new folder at subfolder with properties {name:"B/W"}
		make new folder at grayMap with properties {name:"Booklet"}
		make new folder at grayMap with properties {name:"Duplex"}
		make new folder at grayMap with properties {name:"Single"}
	end tell
end make_subfolders

No, not with plain AppleScript, you need a dialog box to type text :wink:

PS:

or still shorter:


property dc240hotfoldersMap : missing value

tell application "Finder" to set dc240hotfoldersMap to make new folder at (path to shared documents) with properties {name:"DC240_HotFolder"}
make_subfolders("A4")
make_subfolders("A3")

on make_subfolders(N)
	tell application "Finder"
		set subfolder to make new folder at dc240hotfoldersMap with properties {name:N}
		set colorMap to make new folder at subfolder with properties {name:"Color"}
		set grayMap to make new folder at subfolder with properties {name:"B/W"}
	end tell
	make_subsubfolders(colorMap)
	make_subsubfolders(grayMap)
end make_subfolders

on make_subsubfolders(F)
	repeat with oneFolder in {"Booklet", "Duplex", "Single"}
		tell application "Finder" to make new folder at F with properties {name:oneFolder}
	end repeat
end make_subsubfolders

Or:

do shell script "mkdir -p /Users/Shared/DC240_HotFolder/{A4,A3}/{Color,B:W}/{Booklet,Duplex,Single}"

:wink:

Ok, Nigel. that’s just too damn sexy! :lol: Don’t make it look so easy!

Jim Neumann
BLUEFROG

And its not, I spent 2hrs last night (without using google) trying to do something with MKDIR,
For the life of me I could not figure out the multi folder structure.
And even what I did have would have been 5 or 6 lines.

Then I came back here and saw Nigels, … ‘OH’

Thanks Nigel for showing how its done… :slight_smile:

Nigel and StefanK thanks for the usefull reply