문제

I'm trying to get the last modified date for a file in AppleScript. I thought I had this working using:

set thePath to (((path to documents folder) as text) & "speed.txt")
set modDate to modification date of file thePath

and this seemed to return a valid value but when I put this inside an on idle piece of the code I get an:

"can't get class <> of..." error

I saw somewhere else a suggestion to use:

set the modDate to (do shell script "mdls -name kMDItemLasUsedDate " & quoted form of the POSIX path of thePath)

but this returns null. Any ideas on how I can get the modified date?

도움이 되었습니까?

해결책

You need to reference the file.

Try

set thePath to (((path to documents folder) as text) & "speed.txt")
tell application "System Events" to set modDate to modification date of file thePath

or

tell application "System Events" to set thePath to file (((path to documents folder) as text) & "speed.txt")
set modDate to modification date of thePath
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top