简体   繁体   English

如何使用Applescript创建文件夹(包含子文件夹)

[英]How to create a folder (with subfolders) with Applescript

Filemaker has the ability to ake use of AppleScript. Filemaker能够使用AppleScript。

From within Filemaker I want to create a new folder (with the name of a FileMaker field) that holds 6 subfolders. 从Filemaker中我想创建一个包含6个子文件夹的新文件夹(名称为FileMaker字段)。

I am a complete noob where it comes to Applescript. 在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" 我的问题是:创建“Subfolder1”

What is my mistake there? 那里有什么错误?

Help is much appreciated 非常感谢帮助

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

Here is another approach: 这是另一种方法:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM