Page 1 of 1

file attributes

Posted: Mon Jul 06, 2009 9:58 pm
by wake
How do I get the modified date of a file? Sorry if this has been posted, but I did not have any luck searching the forums.




Thanks,
wake

Posted: Tue Jul 07, 2009 6:16 am
by Janschenkel
You have to do it in a roundabout way, by means of the detailed files

Code: Select all

on mouseUp
   answer file "Select a file and I'll tell you the modification date"
   if the result is "Cancel" then exit mouseUp
   put it into theFilePath
   -- extract the filename and folderpath
   set the itemDelimiter to slash
   put item 1 to -2 of theFilePath into theFolderPath
   put item -1 of theFilePath into theFileName
   set the itemDelimiter to comma
   -- save and change the defaultfolder, read the detailed files, restore the defaultfolder
   put the defaultFolder into theOldDefaultFolder
   set the defaultFolder to theFolderPath
   put the detailed files into theFileInfo
   set the defaultFolder to theOldDefaultFolder
   -- remove the file information that we don't need
   filter theFileInfo with (URLEncode(theFileName) & ",*")
   -- the fifth item is the modification date, expressed in seconds
   put item 5 of theFileInfo into theModificationDate
   convert theModificationDate from seconds to internet date
   answer theModificationDate
end mouseUp
HTH,

Jan Schenkel.

Posted: Tue Jul 07, 2009 3:19 pm
by wake
Much appreciated Janschenkel.

That worked like a charm!