So, I have been poking around to see if there was an easy way to use forfiles.exe in one of my script to get a total of the space used by different file types in a share. I present 2 examples. The first gives the wrong total size. It gives only the size of the first file encountered. The second example works and gives the correct total.
The command is to return the size of files in C:\Temp\Test that are PDFs. Works on Win7x64.
So, why is it that the MsgBox causes this. I know I am forgetting something. Any ideas?
Thanks,
Casey
The command is to return the size of files in C:\Temp\Test that are PDFs. Works on Win7x64.
So, why is it that the MsgBox causes this. I know I am forgetting something. Any ideas?
#include <Constants.au3> #include <Array.au3> $n = 0 $strCmdOutput = Run(@ComSpec & " /c " & 'C:\Windows\System32\forfiles.exe' & " /P C:\Temp\Test /S /M *.pdf /C " & '"cmd /c echo @fsize" ', "C:\Temp\Test", @SW_HIDE, 0x2) While 1 $strSTDOUT = StdoutRead($strCmdOutput) If $strSTDOUT <> "" Then MsgBox(0."This doesn't work. The end result is the same size as the first identified file", $strSTDOUT) $n = $n + $strSTDOUT EndIf If @error Then ExitLoop WEnd MsgBox(0, "File size total for all PDFs in the C:\Temp\Test direcotry", $n)
#include <Constants.au3> #include <Array.au3> $n = 0 $strCmdOutput = Run(@ComSpec & " /c " & 'C:\Windows\System32\forfiles.exe' & " /P C:\Temp\Test /S /M *.pdf /C " & '"cmd /c echo @fsize" ', "C:\Temp\Test", @SW_HIDE, 0x2) While 1 $strSTDOUT = StdoutRead($strCmdOutput) If $strSTDOUT <> "" Then $n = $n + $strSTDOUT EndIf If @error Then ExitLoop WEnd MsgBox(0, "File size total for all PDFs in the C:\Temp\Test direcotry", $n)
Thanks,
Casey