Sign in to follow this  
Followers 0
Systems By

Comparing File Sizes

8 posts in this topic

Hi everyone. I need a little bit of help here. I want to call a function depending on the size of a file. I have the following code:

ProgressOn("PST File Check", "Running Processes, Stand By","0 percent", 555, 555)   
; Check if the search was successful

If $search = -1 Then
    MsgBox(0, "Error", "No files/directories matched the search pattern")
    Exit
EndIf

$pbar = 5
sleep(1000)
ProgressSet( $pbar, $pbar & " percent" & @CRLF & @CRLF & @tab & "Checking PST File Size...Stand By...")

While 1
    $file = FileFindNextFile($search)
    If @error Then ExitLoop
    $Size = FileGetSize(@UserProfileDir & "\local settings\application data\microsoft\outlook\" & $file)
    
        MsgBox(4096, "PST file mame: ", $file & @CRLF & " PST file size: " & $Size)
    
    _FileWriteLog($LogFile, "File name: "& $file &" for user: " & $Username & " on PC: " & $Compname & " is " & $Size & " mb(s)")
WEnd

I want to be able to compare $size to > 1600000. Can someone help me out with the syntax? I want to compare the size, then call my email() function.

Thanks in advance.

Arvin

Share this post


Link to post
Share on other sites



If $size > 1600000 Then email()

Am I missing something in your request?


IE Dev ToolbarMSDN: InternetExplorer ObjectMSDN: HTML/DHTML Reference Guide[quote]It is surprising what a man can do when he has to, and how little most men will do when they don't have to. - Walter Linn[/quote]--------------------[font="Franklin Gothic Medium"]Post a reproducer with less than 100 lines of code.[/font]

Share this post


Link to post
Share on other sites

If $size > 1600000 Then email()

Am I missing something in your request?

Sorry if I'm not making myself clear. I want to call my function called email() if the size of the file I am checking is greater than 1,600,000 kb.

Here is my function called email

Func Email($d, $e, $f, $g)
$a = "smtp.gmail.com"
$b = "[blanked for safety]@gmail.com"
$c = "[password]"

Emailx("[blanked for safety]@gmail.com", "xxx@xxx.com", "Oversized PST", "HELP! I'm gonna crash soon!!!!!!")

$h = ObjCreate ("CDO.Message")
With $h
.Subject = $f
.Sender = $d
.From = $d
.To = $e
.TextBody = $g
.AddAttachment ("c:\wkpstlog.txt");needs full path- optional
EndWith
With $h.Configuration.Fields
.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = $a
.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465
.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") = $b
.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = $c
.Item ("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 90
.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
.Update
EndWith
$h.Send
Return
EndFunc

Share this post


Link to post
Share on other sites

I want to call my function called email() if the size of the file I am checking is greater than 1,600,000 kb.

$file = "MyFile.txt"
$size = FileGetSize($file)
If $size > (1600000*1024) Then email()

IE Dev ToolbarMSDN: InternetExplorer ObjectMSDN: HTML/DHTML Reference Guide[quote]It is surprising what a man can do when he has to, and how little most men will do when they don't have to. - Walter Linn[/quote]--------------------[font="Franklin Gothic Medium"]Post a reproducer with less than 100 lines of code.[/font]

Share this post


Link to post
Share on other sites

$file = "MyFile.txt"
$size = FileGetSize($file)
If $size > (1600000*1024) Then email()
I'm getting an error when I run the if statement above. It keeps telling me "Incorrect Number of Parameters in Function Call" with the arrow pointed under where the if statement says "email()". Any ideas?

Share this post


Link to post
Share on other sites

I'm getting an error when I run the if statement above. It keeps telling me "Incorrect Number of Parameters in Function Call" with the arrow pointed under where the if statement says "email()". Any ideas?

Uh, email is your function, you should know. By the looks of it, that function requires 4 parameters.


IE Dev ToolbarMSDN: InternetExplorer ObjectMSDN: HTML/DHTML Reference Guide[quote]It is surprising what a man can do when he has to, and how little most men will do when they don't have to. - Walter Linn[/quote]--------------------[font="Franklin Gothic Medium"]Post a reproducer with less than 100 lines of code.[/font]

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Email($d, $e, $f, $g) this the function and then when you call it you have to include all those

If $size > 1600000 Then email(smtp.gmail.com,"[blanked for safety]@gmail.com,password)
Edited by Hello12345

Share this post


Link to post
Share on other sites

Sorry for the newbie misunderstanding. I'm still learning and very new to AutoIt, but I got it to work thanks to everyone's help. Thank you everyone. I appreciate it.

Arvin

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