我正在尝试获取 AppleScript 中文件的最后修改日期。我以为我可以使用以下方法进行此操作:
set thePath to (((path to documents folder) as text) & "speed.txt")
set modDate to modification date of file thePath
这似乎返回了一个有效值,但是当我将其放入代码的空闲
片段中时,我得到一个:
"can't get class <> of..." error
我在其他地方看到了一个使用建议:
set the modDate to (do shell script "mdls -name kMDItemLasUsedDate " & quoted form of the POSIX path of thePath)
但这会返回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
或
tell application "System Events" to set thePath to file (((path to documents folder) as text) & "speed.txt")
set modDate to modification date of thePath
关于file - 在 AppleScript 中获取文件的最后修改日期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19058156/