我告诉一个程序用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,它将在桌面上。
我承认我是Apple的新手(申请3周后)并且没有真正找到我用AppleScript编写的方法。
谢谢你们的帮助!
答案 0 :(得分: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