dhenry123 Posted October 16, 2007 Share Posted October 16, 2007 (edited) I have a list of file extensions listed on seperate lines in a TXT file that I need to report back to a log file (CSV or TXT) the following information on seperate lines: -file extension, total number of files with that extension, total size of files with that extension Anyone help would be great. Thanks in advance. Edited October 16, 2007 by dhenry123 Link to comment Share on other sites More sharing options...
DW1 Posted October 16, 2007 Share Posted October 16, 2007 I have a list of file extensions listed on seperate lines in a TXT file that I need to report back to a log file (CSV or TXT) the following information on seperate lines. Anyone help would be great. Thanks in advance.-file extension, total number of files with that extension, total size of files with that extensionDidn't you just say you have what you want already? I'm confused"I have a list of file extensions listed on seperate lines in a TXT file""I need to report back to a log file (CSV or TXT) the following information on seperate lines"You say that you start with a text file with file extensions on seperate lines and then you say that you want a text file with file extensions on seperate lines. AutoIt3 Online Help Link to comment Share on other sites More sharing options...
dhenry123 Posted October 16, 2007 Author Share Posted October 16, 2007 (edited) Didn't you just say you have what you want already? I'm confused"I have a list of file extensions listed on seperate lines in a TXT file""I need to report back to a log file (CSV or TXT) the following information on seperate lines"You say that you start with a text file with file extensions on seperate lines and then you say that you want a text file with file extensions on seperate lines.I modified my original posting. Hopefully it is more clear now. See above.Basically, something like this would be great: http://www.drivemonitor.com/dm/FileExtensionReport.htm Edited October 16, 2007 by dhenry123 Link to comment Share on other sites More sharing options...
DW1 Posted October 16, 2007 Share Posted October 16, 2007 Look into the following -FileGetSize -Recursive Searching -FileWrite or FileWriteLine AutoIt3 Online Help Link to comment Share on other sites More sharing options...
PsaltyDS Posted October 16, 2007 Share Posted October 16, 2007 I have a list of file extensions listed on seperate lines in a TXT file that I need to report back to a log file (CSV or TXT) the following information on seperate lines:-file extension, total number of files with that extension, total size of files with that extensionAnyone help would be great. Thanks in advance.Look up FileFindFirstFile(), FileFindNextFile(), and FileGetSize(), plus loop controls with While/WEnd or Do/Until. Try out the examples given first and then start coding. Post your code if you get stuck, you'll get lots of help writing it, but not much writing it for you. 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...
dhenry123 Posted October 16, 2007 Author Share Posted October 16, 2007 Ok, i'm stuck. The log file is not being written. See below code. expandcollapse popup; ; AutoIt Version: 3.0 ; Language: English ; Platform: Win2003 Server ; Author: David Henry ; Orig. Build 10-16-2007 ; ; Script Function: ; IN TEST: Reports back to log file the total size of files for each current remote user waiting in the Outfiles directory. ; ; Version 1.0 10-16-2007 Original build. ; Verify only one copy of the script is running at a time. $g_szVersion = "RemoteUserOutfileFileReport" If WinExists($g_szVersion) Then Exit AutoItWinSetTitle($g_szVersion) $ExtensionsFile = FileOpen ( "C:\TEST\FileExtensions.txt", 0) ;File to Read File Extensions from $LogFile = FileOpen ("C:\TEST\FileExtensionTotalSizeReport.txt", 0) ; File to write results to While 1 $FileExtension = FileReadLine($ExtensionsFile) If @error = -1 Then ExitLoop $FileExtensionTotalSize = "0" $SearchFileFindFirstFile = FileFindFirstFile ( "C:\TEST\Data\*." & $FileExtension) $IncreaseFileExtensionTotalSize = FileGetSize ($SearchFileFindFirstFile) $FileExtensionTotalSize = $FileExtensionTotalSize + $IncreaseFileExtensionTotalSize While 1 $SearchFileFindNextFile = FileFindNextFile ( "C:\TEST\Data\*." & $FileExtension) If @error Then ExitLoop $IncreaseFileExtensionTotalSize = FileGetSize ($SearchFileFindNextFile) $FileExtensionTotalSize = $FileExtensionTotalSize + $IncreaseFileExtensionTotalSize WEnd FileWrite ($LogFile, "Total file size for file extension " & $FileExtension & " = " & $FileExtensionTotalSize) WEnd FileClose($ExtensionsFile) FileClose($LogFile) Exit Link to comment Share on other sites More sharing options...
PsaltyDS Posted October 16, 2007 Share Posted October 16, 2007 (edited) A couple of things:1. You opened the log file in READ mode vice write.2. FileFindFirstFile() returns a HANDLE, that you use to get the files with FileFindNextFile().3. FileFindNextFile() only returns the file name, without the path.Minor hints:a. To increment a variable, you can use a shorthand += operator (as below).$ExtensionsFile = FileOpen ( "C:\TEST\FileExtensions.txt", 0) ;File to Read File Extensions from $LogFile = FileOpen ("C:\TEST\FileExtensionTotalSizeReport.txt", 1) ; 1 = append While 1 $FileExtension = FileReadLine($ExtensionsFile) If @error = -1 Then ExitLoop $FileExtensionTotalSize = "0" $SearchFileFindFirstFile = FileFindFirstFile ( "C:\TEST\Data\*." & $FileExtension) ; Get search handle If @error <> 0 or $SearchFileFindFirstFile = -1 Then ContinueLoop ; Skip to next extension if none found While 1 $SearchFileFindNextFile = FileFindNextFile ($SearchFileFindFirstFile) ; Get next file using search handle If @error Then ExitLoop $IncreaseFileExtensionTotalSize = FileGetSize ("C:\TEST\Data\" & $SearchFileFindNextFile) $FileExtensionTotalSize += $IncreaseFileExtensionTotalSize WEnd FileWrite ($LogFile, "Total file size for file extension " & $FileExtension & " = " & $FileExtensionTotalSize) WEnd FileClose($SearchFileFindFirstFile) ; Close search handle FileClose($ExtensionsFile) FileClose($LogFile) P.S. b. To avoid carpal tunnel syndrom -- use shorter variable names! Edited October 16, 2007 by PsaltyDS 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...
dhenry123 Posted October 16, 2007 Author Share Posted October 16, 2007 Oh wow! An extra set of eyes has definetely helped! Thank you very much! Link to comment Share on other sites More sharing options...
DW1 Posted October 16, 2007 Share Posted October 16, 2007 In your avatar is that you? on an R1? AutoIt3 Online Help Link to comment Share on other sites More sharing options...
dhenry123 Posted October 16, 2007 Author Share Posted October 16, 2007 Oh yes, that is me. I'm a stunter on my free time. That's my 2006 GSXR 750. All white powers Stuntworx cage, subcage and 12 bar. MSR raptor clutch, brembo rear handbrake, dented tank, etc. Just put chrome wheels on it Monday. Link to comment Share on other sites More sharing options...
Foy Posted October 16, 2007 Share Posted October 16, 2007 or $LogFile = FileOpen ("C:\TEST\FileExtensionTotalSizeReport.txt", 9) so if it's not there already you make it and write new stuff on the bottom. 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