2013-03-26 36 views
0

我告訴程序要使用applescript進行備份,然後在完成備份後我告訴它讀取並從plist文件中打開備份位置。之後,我需要它將最新的創建日期複製到桌面上的特定文件。如何以applescript的創建日期複製最新的文件?

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。

我承認我是蘋果公司的新人(蘋果公司的第三週),並沒有真正找到一種我明白在蘋果公司寫這個的方法。

謝謝你們的幫助!

回答

2

試着用這個替換您告訴應用程序 「發現者」 塊:

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 
+0

謝謝!這就像一個魅力! – Breathable 2013-03-27 02:52:12

相關問題