Hello helpful people,
I have been working on this for most of the day but haven’t found an example to fit my needs. (I’m a relative newbie to AppleScript.)
What I need: to create folders and subfolders based on excel data, but the spreadsheets are a little messy.
Code and spreadsheet screenshots
Spreadsheet
For each number in column A, I need a folder containing subfolders for each number in column D.
Here’s what I have:
set numList to getCellList("A", 3, 310)
set myDoc to choose file with prompt "Choose Spreadsheet"
set myFolder to choose folder with prompt "Choose Folder"
repeat with i in numList
tell application "Microsoft Excel" to tell document (myDoc as string) to tell sheet 1 to set cellValue to (value of cell i)
if cellValue is not {"", "outfit", "outfits"} then tell application "Finder" to make new folder at myFolder with properties {name:cellValue}
end repeat
on getCellList(aLetter, startNumber, endNumber)
set myList to {}
repeat with i from startNumber to endNumber
set end of myList to (aLetter & i) as string
end repeat
return myList
end getCellList
This creates the 13 top-level folders I need as well as 295 untitled folders, which I don’t want. I don’t know where to begin with creating the subfolders.
Ideally, a subfolder would be named the number from column D, but only created if there is a number in column B of the same row.
An ideal example based on cell A3: a new folder named “1” is created, containing subfolders “1392440003” and “1381850004”, but no subfolder named “1381500004” because there is no number in B20.
Icing on the cake would be the text from column F of the corresponding row also being in the subfolder name. For example “1392440003 - Insulated Vest - Women’s”.