简体   繁体   English

问:使用Applescript附加文件夹操作

[英]Q: Attaching a Folder Action using Applescript

I am using an apple script to copy files from a ram disk to a connected server. 我正在使用Apple脚本将文件从ram磁盘复制到连接的服务器。 I can make the disk and connect the server automatically but I am having trouble to get the files to copy to the server automatically. 我可以制作磁盘并自动连接服务器,但是我无法将文件自动复制到服务器。

I am using a main app the creates the disk and connects to the server. 我正在使用一个主应用程序,它创建磁盘并连接到服务器。 I also have a folder actions script that will move folders/files placed in the ram disk and move them onto the server. 我还有一个文件夹操作脚本,该脚本将移动放置在ram磁盘中的文件夹/文件并将其移动到服务器上。 However, I have to manually add the FA script via Folder Actions Setup in order for the ram disk to move files to the server because, obviously ram disks and all of their data will be erased upon a restart. 但是,我必须通过“文件夹操作设置”手动添加FA脚本,以使ram磁盘将文件移动到服务器,因为显然ram磁盘及其所有数据在重新启动后将被擦除。 So I need a way to set the folder action of a new folder on a new disk. 因此,我需要一种在新磁盘上设置新文件夹的文件夹操作的方法。

I have tried to use the following command at the end of the main app but it either doesn't work or it errors out. 我试图在主应用程序的末尾使用以下命令,但是它不起作用或出错。 tell application "System Events" to attach action to folder "Filemaker" of disk "ramdisk" using "/Library/Scripts/Folder Action Scripts/FMBackups.scpt" 告诉应用程序“系统事件”,使用“ / Library / Scripts / Folder Action Scripts / FMBackups.scpt”将操作附加到磁盘“ ramdisk”的文件夹“ Filemaker”

Even if you're not sure on whether something will work, any useful suggestions would be greatly appreciated! 即使您不确定是否可以正常工作,任何有用的建议也将不胜感激!

Your syntax was OK in old versions (at least up to 10.6.8). 您的语法在旧版本(至少为10.6.8以下)中还可以。 Since it has been depreciated and it must be replaced by "make" : 由于它已经贬值,因此必须用“ make”代替:

tell application "System Events"
make new folder action at end of folder actions with properties {enabled:true, name:"FolderName", path:"path:to:my:folder}
tell folder action "FolderName" to make new script at end of scripts with properties {name:"myScriptName.scpt"}
end tell

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

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