Error -1728 when getting modification date

I have a little snippet of Applescript:

set theFilesPath to POSIX path of ((path to desktop from user domain as string) & "test.txt")
tell application "Finder"
	return modification date of theFilesPath
end tell

All it’s returning is

error “Can’t get modification date of "/Users/user/Desktop/test.txt".” number -1728 from modification date of “/Users/user/Desktop/test.txt”

How can I make this work?

-Wilson

Hi,

AppleScript expects HFS paths (colon separated)


set theFilesPath to ((path to desktop as text) & "test.txt")
tell application "Finder"
	return modification date of file theFilesPath
end tell

facepalm Thanks. I knew that. But overlooked it. :stuck_out_tongue:

Why ask the Finder when System Events is able to do the job for Hfs AND for Unix paths ?


set HFSpath to (path to desktop as text) & "cmd unix.pdf"
set UNIXpath to POSIX path of HFSpath
tell application "System Events"
	modification date of file HFSpath
	--> date "samedi 15 septembre 2012 17:29:26"
	modification date of file UNIXpath
	--> date "samedi 15 septembre 2012 17:29:26"
end tell

Yvan KOENIG (VALLAURIS, France) mercredi 17 octobre 2012 15:24:05

Yet another reason to use System Events when you don’t have any user interaction! :slight_smile: