0
下面的AppleScript代碼獲得最後添加的文件,AppleScript - 獲取文件夾中唯一文件的名稱?
tell application "Finder"
set latestFile to item 1 of (sort (get files of (path to downloads folder)) by creation date) as alias
set fileName to latestFile's name
end tell
來源:How to get the latest downloaded file name with applescript programatically?
但是,如果該文件夾中只有一個文件失敗。如何解決這個問題?
這個偉大的工程忽略錯誤。謝謝。我們如何指定一個像這樣的路徑「/ MainFolder1/SubFolder1」? –
嚴格說話'/ MainFolder1'位於啓動磁盤的頂層。這是打算? Finder希望(以冒號分隔的)字符串路徑以磁盤名稱(也是啓動磁盤)開始。您可以編寫「獲取文件夾的文件」Macintosh HD:MainFolder1:SubFolder1:「...' – vadian
再次感謝。你非常有幫助。 –