file attributes

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
wake
Posts: 21
Joined: Thu Jun 25, 2009 6:15 pm

file attributes

Post by wake » Mon Jul 06, 2009 9:58 pm

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

Janschenkel
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 977
Joined: Sat Apr 08, 2006 7:47 am
Contact:

Post by Janschenkel » Tue Jul 07, 2009 6:16 am

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.
Quartam Reports & PDF Library for LiveCode
www.quartam.com

wake
Posts: 21
Joined: Thu Jun 25, 2009 6:15 pm

Post by wake » Tue Jul 07, 2009 3:19 pm

Much appreciated Janschenkel.

That worked like a charm!

Post Reply