View Full Version : Querying file size

11 November 2006, 05:08 PM
Hi, is there a MEL or DOS command which will
give me the size of a file? I need to check if files
are < 1 kb. Couldn`t find anything useful so far.
tia buexe

11 November 2006, 10:16 PM
There is probably and easier way to do this, but here is what I came up with:

global proc int getFileSize(string $filePath) {
string $dir = system("dir \"" + $filePath + "\"");
string $dirArray[];
string $returnString;

tokenize $dir " " $dirArray;
$returnString = `substituteAllString $dirArray[size($dirArray) -7] "," ""`;
return $returnString;

A few things to keep in mind.

1. This will only work on windows
2. Make sure you use backslashes for your path.
3. Since the backslash is an escape character make sure your string is encoded.


incorrect useage:

getFileSize("c:/some folder/some file.mb");
getFileSize("c:\some folder\some file.mb");

correct useage:

getFileSize("c:\\some folder\\some file.mb");

I haven't tested this very heavily, so use it with caution. If it doesn't work, or someone finds and easier way, let me know.

CGTalk Moderation
11 November 2006, 10:16 PM
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.