Folder Sub Folder creation from excel

Hello,

I am stuck … I need the script to create folders from an excel but also add sub and sub sub folders to each of the folder created in from the excel data. The sub and sub sub folder names are same for all the folders that need to be created

Folder 1
–Sub Folder 1
–Sub Folder 2
— Sub Sub Folder 2.1
----Sub Sub Sub Folder 2.1.1
----Sub Sub Sub Folder 2.1.2
----Sub Sub Sub Folder 2.1.3
— Sub Sub Folder 2.2
---- Sub Sub Sub Folder 2.1.1
–Sub Folder 3
— Sub Sub Sub Folder 3.1.1
–Sub Folder 4
— Sub Sub Sub Folder 4.1.1

This is how far I got to … the script is not creating sub or sub sub folders and error pops up that the folder already exists.

set _excel to choose file

set _folder to choose folder

tell application “Microsoft Excel”

open _excel

set theNames to value of range “A1:c6”

close active workbook

end tell

repeat with aName in theNames

set fullName to item 1 of aName & space & item 2 of aName & space & item 3 of aName

tell application “Finder”

tell application “Finder” to make new folder at _folder with properties {name:fullName}

– set thisFolder to make new folder at fullName with properties {name:“Copy”}

make new folder at fullName with properties {name:“Copy”}

make new folder at _folder with properties {name:“Layout”}

set subFolder1 to make new folder at loc2 with properties {name:“Links”}

set anotherSubFolder to make new folder at subFolder1 with properties {name:“Final”}

set anotherSubFolder1 to make new folder at subFolder1 with properties {name:“Original”}
set anotherSubFolder4 to make new folder at subFolder1 with properties {name:“Working”}

make new folder at loc2 with properties {name:“Mocks”}
set anotherSubFolder3 to make new folder at subFolder2 with properties {name:“Cover Jpegs”}

make new folder at _folder with properties {name:“Misc”}
make new folder at _folder with properties {name:“PDF”}
make new folder at loc3 with properties {name:“Email for Approval”}

make new folder at loc3 with properties {name:“Press PDF”}

make new folder at loc3 with properties {name:“Proof PDF”}

end tell

end repeat

The same original post was also at https://forum.latenightsw.com/t/applescript-to-create-folders-from-excel-with-constant-sub-and-sub-sub-folders/1786 with very elegant ASOC solutions provided. With credit to roosterboy who deciphered the desired folder layout from the original post I came up with a not so elegant AppleScript solution that I wanted to share for the benefit of less advanced scripters like myself who are not yet comfortable with ASOC. The script is very basic and has no error handling but might prove helpful to someone dealing with a similar problem. The script assumes that the desired title for the top level folder is contained in the first 3 columns of row 1 of the target spreadsheet. I had to use “Numbers” for the spreadsheet since I don’t have “Microsoft Excel.”

use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions

display dialog "Select a spreadsheet file to get top folder name from"

set _numbers to choose file

display dialog "Select a directory to place folders in"

set _folder to choose folder

set theNames to {}

tell application "Numbers"
	open _numbers
	tell the first table of the active sheet of document 1
		set theNames to value of cells in range "A1:C1"
		set fullName to item 1 of the theNames & " " & item 2 of theNames & " " & item 3 of theNames
	end tell
end tell

tell application "Finder"
	set topFolder to make new folder at _folder with properties {name:fullName}
	set copyFolder to make new folder at topFolder with properties {name:"Copy"}
	set layoutFolder to make new folder at topFolder with properties {name:"Layout"}
	set linksFolder to make new folder at layoutFolder with properties {name:"Links"}
	set finalFolder to make new folder at linksFolder with properties {name:"Final"}
	set originalFolder to make new folder at linksFolder with properties {name:"Original"}
	set workingFolder to make new folder at linksFolder with properties {name:"Working"}
	set mocksFolder to make new folder at layoutFolder with properties {name:"Mocks"}
	set jpegsFolder to make new folder at mocksFolder with properties {name:"Cover Jpegs"}
	set miscFolder to make new folder at topFolder with properties {name:"Misc"}
	set pdfsFolder to make new folder at topFolder with properties {name:"PDFs"}
	set emailFolder to make new folder at pdfsFolder with properties {name:"Email for Approval"}
	set pressFolder to make new folder at pdfsFolder with properties {name:"Press PDF"}
	set proofFolder to make new folder at pdfsFolder with properties {name:"Proof PDF"}
end tell