Creating a folder inside another folder using Applescript?


#1

Theoretically, the folder object has a container property that can be another folder. I’ve tried three things:

Attempt 1:

set parentFolder to folder whose name is "parentName"
make new folder with properties { name:"folderName", container:parentFolder }

Attempt 2:

set parentFolder to folder whose name is "parentName"
set newFolder to make new folder with properties { name: "folderName" }
set container of newFolder to parentFolder

Attempt 3:

set parentFolder to folder whose name is "parentName"
set newFolder to make new folder with properties { name: "folderName" }
add newFolder to parentFolder

Version 1 complains unhelpfully that “AppleEvent Handler Failed”

Version 2 says “Can’t set container of folder to folder id “mZZKqBxRm8k” of default document”

Version 3 says the “to” specifier is invalid.

Any suggestions?


#2

Never mind, solved it!

set parentFolder to folder whose name is "parentName"
set newFolder to make new folder with properties { name: "folderName" } at end of folders of parentFolder