masvil Posted December 23, 2006 Posted December 23, 2006 I have to found the larger file in a given path. FileFindFirstFile / FileFindNextFile ... then?
xcal Posted December 23, 2006 Posted December 23, 2006 FileGetSize? How To Ask Questions The Smart Way
masvil Posted December 23, 2006 Author Posted December 23, 2006 FileGetSize?Sure, but I need to automatically found and handle the larger file.
xcal Posted December 23, 2006 Posted December 23, 2006 Stick the file sizes in an array, and sort the array. How To Ask Questions The Smart Way
xcal Posted December 23, 2006 Posted December 23, 2006 (edited) $file = 'none found' $size = 0 $path = 'c:\windows\' ;your path here $first = FileFindFirstFile($path & '*.*') While 1 $next = FileFindNextFile($first) If @error Then ExitLoop If StringInStr(FileGetAttrib($path & $next), 'D') Then ContinueLoop $check = FileGetSize($path & $next) If $check > $size Then $size = $check $file = $path & $next EndIf WEnd MsgBox(0, '', _ 'File is: ' & $file & @CRLF & _ 'Size is: ' & StringFormat('%.2f', $size / 1048576) & 'MB') Edited December 23, 2006 by xcal How To Ask Questions The Smart Way
masvil Posted December 24, 2006 Author Posted December 24, 2006 It works great, thanx I was playing with following, but it doesn't return size, so your is better for me. $dir = @WindowsDir RunWait(@ComSpec & ' /c dir "' & $dir & '" /B /D /O-S /A RASH>dir.txt',@ScriptDir, @SW_HIDE) $larger = FileReadLine("dir.txt") FileDelete(@ScriptDir & "\dir.txt") MsgBox(1,"","larger file is: " & $larger)
xcal Posted December 24, 2006 Posted December 24, 2006 No problem, glad to help. How To Ask Questions The Smart Way
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