PDA

View Full Version : How to find details of file date time and file size via mel?


rohitdantkale
09-23-2010, 08:05 AM
Hi Friends, Can anybody help me for creating the function by which i can find the date and time of file when it was last accessed and modified with the size of file in MBs,
i want to query my project files about when it was last modifed,
Thanx in advance...

NaughtyNathan
09-23-2010, 10:42 AM
I would suggest doing such a thing in python rather than MEL, but if that's not an option you'll probably have to use the MEL command: system to dir the file and parse it's output using tokenize to extract the data you want.

string $fileData = `system "dir c:\\image.bmp"`;:nathaN

ewerybody
09-28-2010, 11:05 AM
why not this:
python("import os");
float $secSinceEpoch = python("os.path.getmtime('" + `file -q -sn` + "')");there is getatime and getctime for access and creationtime as well :D

rohitdantkale
09-29-2010, 08:29 AM
thankyou friends for your replies.....
I have one more thing to ask, is there any command to sort the files in my textScrollList according to the date of the files in that list, i found the date and time, but now i want to compare there timings and find sort them by latest one, the program for comparison will be very long and slower, is there any function for it?
thanx again for ur replies....
i'm using mel, if u have any solution through python then plz also tell me how can i use python functions through mel,

rohitdantkale
09-29-2010, 09:48 AM
why not this:
python("import os");
float $secSinceEpoch = python("os.path.getmtime('" + `file -q -sn` + "')");there is getatime and getctime for access and creationtime as well :D

this returns me something like this: // Result: 1285663366.158228 // , i dont know what this figure is indicating, it doesnt look like a date nor time, :curious:

ewerybody
09-29-2010, 10:02 AM
$secSinceEpoch (http://en.wikipedia.org/wiki/Epoch_%28reference_date%29#Computing)
this is standard in python. It gives you the number of seconds since a certain point in time. And this point is not bound to winter/summer time, regional time settings or the Y2K-bug. Thats why its superior to the usual yyyymmddhhmmss-thing and its simple to use!
If the number is bigger > more seconds > its a newer date!

CGTalk Moderation
09-29-2010, 10:02 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.