Extracting File Size

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
warrenk
Posts: 110
Joined: Sun Sep 21, 2008 5:39 am

Extracting File Size

Post by warrenk » Tue Oct 14, 2008 4:35 pm

I loaded a list of files (detail information) into tAllFiles. How do I extract the size from the list into a variable? Is there a command that allows me to extract this?

repeat for each line tFile in tAllFiles
...not sure about the command to extract the file size?

Thanks,
Warren

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

Post by Janschenkel » Tue Oct 14, 2008 4:54 pm

The file size (in bytes) is in the second item - and if you're on Mac, you may also be interested in the third item for _very_ old files which also contain a resource fork.

Code: Select all

put the detailed files into tDetailedFiles
repeat for each line tDetailedFile in tDetailedFiles
  put item 1 of tDetailedFile into tFileName
  put item 2 of tDetailedFile into tFileSize
  divide tFileSize by 1024 -- convert to KB
  put tFileName & comma & tFileSize & return after tFileNamesAndSizes
end repeat
delete char -1 of tFileNamesAndSizes -- remove trailing return
If you're looking at converting the creation or modification dates, those are given as 'seconds', so you're looking at

Code: Select all

  put item 4 of tDetailedFile into tCreationDate
  convert tCreationDate from seconds to system date and system time
Hope this helped,

Jan Schenkel.
Quartam Reports & PDF Library for LiveCode
www.quartam.com

warrenk
Posts: 110
Joined: Sun Sep 21, 2008 5:39 am

Post by warrenk » Tue Oct 14, 2008 5:00 pm

Jan,

Thanks for taking your time to help me out. Really appreciate it! :lol:

Warren

Post Reply