Ali*_*ade 2 applescript file last-modified
我正在尝试获取AppleScript中文件的最后修改日期。我以为我使用以下方法工作:
set thePath to (((path to documents folder) as text) & "speed.txt")
set modDate to modification date of file thePath
Run Code Online (Sandbox Code Playgroud)
这似乎返回了一个有效值,但是当我将其放入on idle一段代码中时,我得到了:
“无法获得...的类<>”错误
我在其他地方看到了使用建议:
set the modDate to (do shell script "mdls -name kMDItemLasUsedDate " & quoted form of the POSIX path of thePath)
Run Code Online (Sandbox Code Playgroud)
但这又回来了null。关于如何获取修改日期的任何想法?
您需要引用该文件。
尝试
set thePath to (((path to documents folder) as text) & "speed.txt")
tell application "System Events" to set modDate to modification date of file thePath
Run Code Online (Sandbox Code Playgroud)
要么
tell application "System Events" to set thePath to file (((path to documents folder) as text) & "speed.txt")
set modDate to modification date of thePath
Run Code Online (Sandbox Code Playgroud)