【发布时间】:2023-03-24 01:07:01
【问题描述】:
我有一个 AppleScript 可以挂载网络 smb 共享,创建目标文件夹(如果它们不存在),然后通过替换将文件复制到目标文件夹。然后它会卸载 smb 共享。
我进行了大量编辑以删除敏感信息,但要点是:
-- AppleScript to backup crucial files from server without TimeMachine
-- J Harris 20-12-13
-- v1 created alias and used this for folder creation 26-12-13
-- v2 added share4 folder 03-01-14
-- Mount the destination and create an alias
mount volume "smb://<username>:<password>@server.domain.com/sharename"
set server to result as alias
-- do the copy
tell application "Finder"
-- Create destination folder & copy the * files. This will overwrite all files
if not (exists POSIX file "/Volumes/sharename/share1") then make new folder with properties {name:"share1"} at server
duplicate items of folder "Macintosh HD:<location to share1>" to POSIX file "/Volumes/sharename/share1" with replacing
--Create destination folder and copy the ** files. This will overwrite all files
if not (exists POSIX file "/Volumes/sharename/share2") then make new folder with properties {name:"share2"} at server
duplicate items of folder "Macintosh HD:<location to share2>" to POSIX file "/Volumes/sharename/share2" with replacing
--Create destination folder and copy *** files. This will overwrite all files
if not (exists POSIX file "/Volumes/sharename/share3") then make new folder with properties {name:"share3"} at server
duplicate items of folder "Macintosh HD:<location to share3>" to POSIX file "/Volumes/sharename/share3" with replacing
--Create destination folder and copy all local **** files. This will overwrite all files
if not (exists POSIX file "/Volumes/sharename/share4") then make new folder with properties {name:"share4"} at server
duplicate items of folder "Macintosh HD:<location to share4>" to POSIX file "/Volumes/sharename/share4" with replacing
-- Unmount the destination
eject server
end tell
我将它保存为一个应用程序,它运行良好。
然后我尝试使用 Lingon 来安排任务以编辑 launchd。我读过你不能将launchd指向应用程序本身,你必须将它指向app/Contents/MacOS/Applet
当它运行时,我收到一个 AppleScript 编辑器错误“未找到文件夹”。
有人有什么想法吗?
提前致谢
约翰
【问题讨论】:
标签: applescript launchd