Hi. Welcome to MacScripter.
It’s possible to write a recursive routine using the Finder, but “mkdir” shell scripts work faster and are easier to write — once you’re used to them!
-- To get subfolders "1", "2", "3", and "4" in the "RENDERS" folder only:
property hierarchy : "{'ANI & PATENT',ARCHIVE,IMAGES,'ONLINE INFO',PQM,PROOFREADING,PROOFS,RENDERS/{1,2,3,4},'SOURCE DOCS'}"
-- To get them in, say, both "PROOFS" and "RENDERS", use this instead:
-- property hierarchy : "{'ANI & PATENT',ARCHIVE,IMAGES,'ONLINE INFO',PQM,PROOFREADING,{PROOFS,RENDERS}/{1,2,3,4},'SOURCE DOCS'}"
-- Or to get them in all the folders:
-- property hierarchy : "{'ANI & PATENT',ARCHIVE,IMAGES,'ONLINE INFO',PQM,PROOFREADING,PROOFS,RENDERS,'SOURCE DOCS'}/{1,2,3,4}"
tell application "Finder"
set selectedFolders to selection
if (count selectedFolders) > 0 then
repeat with aFolder in selectedFolders
if (aFolder's class is folder) then set aFolder's contents to aFolder as alias
end repeat
set theLocations to selectedFolders's aliases
if ((count theLocations) is 0) then error "No folders in the selection!"
else if ((count Finder windows) > 0) then
set folderAlias to (target of front Finder window) as alias
set theLocations to quoted form of POSIX path of folderAlias
else
error "No selection and no container windows open!"
end if
end tell
repeat with thisLocation in theLocations
do shell script "mkdir -p " & (quoted form of POSIX path of thisLocation) & hierarchy
end repeat
Edit: Here’s a devious variation which only needs to call ‘do shell script’ once, even when multiple folders are selected. I don’t know if it’s necessarily any better. (Further edit: Script below debugged to allow for single-folder selection (!) and both scripts now give explanatory error messages when the running conditions aren’t met.)
-- To get subfolders "1", "2", "3", and "4" in "RENDERS" only:
property hierarchy : "{'ANI & PATENT',ARCHIVE,IMAGES,'ONLINE INFO',PQM,PROOFREADING,PROOFS,RENDERS/{1,2,3,4},'SOURCE DOCS'}"
-- To get them in, say, both "PROOFS" and "RENDERS", use this instead:
-- property hierarchy : "{'ANI & PATENT',ARCHIVE,IMAGES,'ONLINE INFO',PQM,PROOFREADING,{PROOFS,RENDERS}/{1,2,3,4},'SOURCE DOCS'}"
-- Or to get them in all the folders:
-- property hierarchy : "{'ANI & PATENT',ARCHIVE,IMAGES,'ONLINE INFO',PQM,PROOFREADING,PROOFS,RENDERS,'SOURCE DOCS'}/{1,2,3,4}"
tell application "Finder"
set selectedFolders to selection
if (count selectedFolders) > 0 then
repeat with aFolder in selectedFolders
if (aFolder's class is folder) then
set folderAlias to aFolder as alias
set aFolder's contents to quoted form of POSIX path of folderAlias
end if
end repeat
set theLocations to selectedFolders's text
set locationCount to (count theLocations)
if (locationCount is 1) then
set theLocations to beginning of theLocations
else if (locationCount > 1) then
-- Bracket the obtained folder paths together like the folder names in 'hierarchy'.
set astid to AppleScript's text item delimiters
set AppleScript's text item delimiters to ","
set theLocations to "{" & (selectedFolders's text) & "}/"
set AppleScript's text item delimiters to astid
else
error "No folders in the selection!"
end if
else if ((count Finder windows) > 0) then
set folderAlias to (target of front Finder window) as alias
set theLocations to quoted form of POSIX path of folderAlias
else
error "No selection and no container windows open!"
end if
end tell
do shell script "mkdir -p " & theLocations & hierarchy