我已经调整了“添加 - 新项目警报”苹果脚本并将其作为文件夹操作应用于我的“卷”文件夹。调整后的脚本应该检测何时插入新的 USB 驱动器并打开应用程序(Automator 工作流程),然后将文件复制到驱动器并弹出它。
第一期
当我在 AppleScript 编辑器中运行脚本时,它可以工作。但是,当插入 USB 驱动器时脚本自动运行时,它只会告诉我它已检测到新驱动器并且没有打开应用程序。我正在使用 do shell 脚本“open -a Conference_Copy_Paste”来打开位于我的应用程序文件夹中的应用程序(请参阅下面的 AppleScript 代码)。
使用的代码开始--->
属性 dialog_timeout : 0 -- 设置对话自动应答之前的时间量。
执行 shell 脚本“open -a Conference_Copy_Paste”
在收到 added_items 后将文件夹项目添加到 this_folder 尝试告诉应用程序“Finder”--获取文件夹的名称 将 folder_name 设置为 this_folder 的名称 end tell
-- find out how many new items have been placed in the folder
set the item_count to the number of items in the added_items
--create the alert string
set alert_message to ("Folder Actions Alert:" & return & return) as Unicode text
if the item_count is greater than 1 then
set alert_message to alert_message & (the item_count as text) & " new items have "
else
set alert_message to alert_message & "One new item has "
end if
set alert_message to alert_message & "been placed in folder " & «data utxt201C» & the folder_name & «data utxt201D» & "."
set the alert_message to (the alert_message & return & return & "Would you like to view the added items?")
set the user_choice to the button returned of the result
if user_choice is "Yes" then
tell application "Finder"
--go to the desktop
activate
--open the folder
open this_folder
--select the items
reveal the added_items
end tell
end if
end try
结束将文件夹项目添加到
<--- 使用的代码结束
第 2 期
使用此应用程序大约 10 次后,我在运行它时开始出现错误。错误显示“您无权将文件“任何文件”保存在“任何文件夹”文件夹中。” 解决此问题的唯一方法是重新启动我的系统。有没有更好的方法来解决这个特定问题?
Automator 应用程序的工作流程运行“获取指定的查找器项目”、“复制查找器项目”,然后运行“弹出磁盘”。
提前感谢任何可以帮助我解决这个问题的人。我迫切需要它来工作,因为我必须将文件复制并粘贴到 1k USB 驱动器以进行会议。