0

我告诉一个程序用 applescript 备份,然后在它完成备份后我告诉它从 plist 文件中读取并打开备份位置。之后,我需要它将最新的创建日期复制到桌面上的特定文件中。

try
    tell application "xxxxx"
        backup
    end tell
on error errmsg
    display dialog errmsg buttons {"xxxxx Backup Failed"}
end try

set the plistfile_path to "~/Library/Preferences/com.xxxxx.Xxxxx.plist"

tell application "System Events"
    set p_list to property list file (plistfile_path)
    value of property list item "backupPath" of p_list
    open result

    tell application "Finder"
        set itemGroup to sort (get every document file of the front Finder window) by creation date
        duplicate of (item 1) of the (front Finder window) to folder "LOGS-I-NEED:"
    end tell
end tell

我让它复制文件夹中的第一个或最后一个文件,但我需要复制最新的创建日期文件,该文件将在最后 10 秒内。我需要将其复制到的文件夹是 LOGS-I-NEED,它将位于桌面上。

我承认我是 applescript 的新手(进入 applescript 3 周)并且还没有真正找到我理解的在 applescript 中写这个的方法。

谢谢各位帮忙!

4

1 回答 1

2

尝试用这个替换你的告诉应用程序“Finder”块:

tell application "Finder"
    set itemGroup to sort (get every document file of the front Finder window) by creation date
    set now to current date
    set sec to 10
    repeat with currentItem in itemGroup
        if (now - (creation date of currentItem)) ≤ sec then
            duplicate currentItem to folder "LOGS-I-NEED:"
        end if
    end repeat
end tell
于 2013-03-26T08:56:03.377 回答