spac3m0nk3y Posted November 13, 2007 Share Posted November 13, 2007 I've got a function that puts filenames with a certain beginning ID in an array. $ID = _GUICtrlListViewGetItemText($lstProviders, -1, 1) $NumFiles = _FileListToArrayEx($filePath, $ID & '*.doc') This works fine, except I would also like to add the size of the file to the array, so I can display that in a listview. Is there a way I can do this? I tried it this way, but it always shows zero filesize: If IsArray($NumFiles) Then GUICtrlSetData($getLst, '');Empty the control $lstProviders For $i = 1 To $NumFiles[0] GUICtrlCreateListViewItem($NumFiles[$i] & Chr(124) & FileGetSize($NumFiles[$i]) & Chr(124), $getLst) Next EndIf Website: http://www.mayniac.org Link to comment Share on other sites More sharing options...
PsaltyDS Posted November 13, 2007 Share Posted November 13, 2007 FileGetSize() needs a full path to the file. Are you by any chance giving it only the file name without the folder path? Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
spac3m0nk3y Posted November 13, 2007 Author Share Posted November 13, 2007 FileGetSize() needs a full path to the file. Are you by any chance giving it only the file name without the folder path? Ugh, you were right, once I added the path, it showed the filesize, DUH!Ok, now is there an algorithm that I can perform on the filesize to have it only show something like 60KB or 1.5MB or something like that, instead of the actual bytes? Website: http://www.mayniac.org Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted November 13, 2007 Moderators Share Posted November 13, 2007 (edited) FileGetSize(...) / 1024 = kb (FileGetSize(...) / 1024) / 1024 = mb Edit: Added iteration... I'm sure you get the picture now. Edited November 13, 2007 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Monamo Posted November 13, 2007 Share Posted November 13, 2007 Ugh, you were right, once I added the path, it showed the filesize, DUH! Ok, now is there an algorithm that I can perform on the filesize to have it only show something like 60KB or 1.5MB or something like that, instead of the actual bytes? Here's what I typically use when working with the "bytes-only" return: Const $1GB = 1024 * 1024 * 1024 Const $1MB = 1024 * 1024 Const $1KB = 1024 $targetFile = "C:\pagefile.sys" $SpaceCalc = FileGetSize($targetFile) Select Case $SpaceCalc > $1GB $sApproximateSpace = $SpaceCalc / $1GB $sComparison = "GB" Case $SpaceCalc > $1MB And $SpaceCalc < $1GB $sApproximateSpace = $SpaceCalc / $1MB $sComparison = "MB" Case $SpaceCalc >= "0" And $SpaceCalc < $1MB $sApproximateSpace = $SpaceCalc / $1KB $sComparison = "KB" Case Else EndSelect If StringInStr($sApproximateSpace, ".") Then $sApproximateSpace = StringTrimRight($sApproximateSpace, StringLen($sApproximateSpace) - StringInStr($sApproximateSpace, ".") - 1) Else EndIf MsgBox(64, "Approximate (rounded) file size", $sApproximateSpace & " " & $sComparison) - MoChr(77)& Chr(97)& Chr(100)& Chr(101)& Chr(32)& Chr(121)& Chr(97)& Chr(32)& Chr(108)& Chr(111)& Chr(111)& Chr(107)-------I've told you 100,000 times not to exaggerate!-------Don't make me hit you with my cigarette hand...-------My scripts:Random Episode Selector, Keyboard MouseMover, CopyPath v2.1, SmartRename for XP,Window Tracer[sup]New![/sup] Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now