Buyer Pro
Buyer Pro

Reputation: 207

How to create a folder (with subfolders) with Applescript

Filemaker has the ability to ake use of AppleScript.

From within Filemaker I want to create a new folder (with the name of a FileMaker field) that holds 6 subfolders.

I am a complete noob where it comes to Applescript.

This is my script so far:

tell application "FileMaker Pro Advanced"
set folder_name to cell "FolderName" of current record
end tell
tell application "Finder"
     activate
     make new folder at folder "Desktop" of folder "dick" of folder "Users" of startup disk with properties {name:folder_name}
end tell
tell application "Finder"
     activate
        make new folder at folder {name:folder_name} of folder "Desktop" of folder "dick" of folder "Users" of startup disk with properties {name:"subfolder"}
end tell

My problem is: the creation of "Subfolder1"

What is my mistake there?

Help is much appreciated

Upvotes: 1

Views: 4355

Answers (2)

adayzdone
adayzdone

Reputation: 11238

Here is another approach:

set myPath to POSIX path of ((path to desktop as text) & folder_name & ":subfolder")
do shell script "mkdir -p " & myPath

Upvotes: 2

Vighnesh Pai
Vighnesh Pai

Reputation: 1843

When you crate a new folder you can define various properties, but when refering to the folder just use the name, for example:

make new folder at folder folder_name of folder "Desktop" of folder "dick" of folder "Users" of startup disk with properties {name:"subfolder"}

Note that the result returned from making a new folder is a reference to that folder, so you can also do something like:

tell application "Finder"

  set newFolder to (make new folder at folder "Desktop" of folder "dick" of folder "Users" of startup disk with properties {name:folder_name})

  make new folder at newFolder with properties {name:"subfolder"}

end tell

Upvotes: 2

Related Questions