Sign in to follow this  
Followers 0
masvil

larger file

7 posts in this topic

I have to found the larger file in a given path.

FileFindFirstFile / FileFindNextFile ... then?

Share this post


Link to post
Share on other sites



FileGetSize?

Sure, but I need to automatically found and handle the larger file.

Share this post


Link to post
Share on other sites

#5 ·  Posted (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 by xcal

Share this post


Link to post
Share on other sites

It works great, thanx :P

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)

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0