Angrysteel Posted January 13, 2010 Share Posted January 13, 2010 I have several log file i would like to pull text from and write to a new text file. I am not sure how to get started on this. Sample of the Log file: Backing up c:/med-edi/ME.BP.O/MENU.DRIVER Backing up c:/med-edi/ME.BP.O/MENU.WINDOW Backing up c:/med-edi/ME.BP.O/PC Backing up c:/med-edi/ME.CF Backing up c:/med-edi/ME.CF/.Type1 Backing up c:/med-edi/ME.CF/01.SND Backing up c:/med-edi/ME.CF/DSM01.SND Backing up c:/med-edi/ME.CF/EDISTAT.txt Backing up c:/med-edi/ME.CF/STO.449200 WARNING: The magic number of this file is byte-swapped, indicating the file did not originate on this platform. Saving as SYSTEM type file! Backing up c:/med-edi/ME.CTL Backing up c:/med-edi/ME.POPF Backing up c:/med-edi/ME.TPF Backing up c:/med-edi/reg Backing up c:/med-edi/reg/dump.REG.RTF Backing up c:/med-edi/reg/REG.RTF Backing up c:/med-edi/TEMP Backing up c:/med-edi/USER.MPQ Backing up c:/med-edi/USER.MPQ/.Type1 Backing up c:/med-edi/VOC Backing up c:/med-edi/VOCLIB Total files: 241 Total bytes : 8087823 Elapsed Time: 00:00:05 222 operating system files processed, 0 broken, totalling 405313 data bytes. 19 UniVerse files processed, 0 corrupted. 36666 UniVerse records processed, 0 corrupted, totalling 7682510 data bytes. 0 extended keys processed, 0 not supported at specified revision level. EndOfUvbackup I want to extract from Total files: ...... EndOfUvbackup Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 13, 2010 Moderators Share Posted January 13, 2010 Angrysteel,If Total files: and EndOfUvbackup appear nowhere else in the text, then _StringBetween should work: expandcollapse popup#Include <String.au3> $sText = _ "Backing up c:/med-edi/ME.BP.O/MENU.DRIVER" & @CRLF & _ "Backing up c:/med-edi/ME.BP.O/MENU.WINDOW" & @CRLF & _ "Backing up c:/med-edi/ME.BP.O/PC" & @CRLF & _ "Backing up c:/med-edi/ME.CF" & @CRLF & _ "Backing up c:/med-edi/ME.CF/.Type1" & @CRLF & _ "Backing up c:/med-edi/ME.CF/01.SND" & @CRLF & _ "Backing up c:/med-edi/ME.CF/DSM01.SND" & @CRLF & _ "Backing up c:/med-edi/ME.CF/EDISTAT.txt" & @CRLF & _ "Backing up c:/med-edi/ME.CF/STO.449200" & @CRLF & _ "WARNING: The magic number of this file is byte-swapped, indicating" & _ "the file did not originate on this platform." & @CRLF & _ "Saving as SYSTEM type file!" & @CRLF & _ "Backing up c:/med-edi/ME.CTL" & @CRLF & _ "Backing up c:/med-edi/ME.POPF" & @CRLF & _ "Backing up c:/med-edi/ME.TPF" & @CRLF & _ "Backing up c:/med-edi/reg" & @CRLF & _ "Backing up c:/med-edi/reg/dump.REG.RTF" & @CRLF & _ "Backing up c:/med-edi/reg/REG.RTF" & @CRLF & _ "Backing up c:/med-edi/TEMP" & @CRLF & _ "Backing up c:/med-edi/USER.MPQ" & @CRLF & _ "Backing up c:/med-edi/USER.MPQ/.Type1" & @CRLF & _ "Backing up c:/med-edi/VOC" & @CRLF & _ "Backing up c:/med-edi/VOCLIB" & @CRLF & _ "" & @CRLF & _ "Total files: 241 Total bytes : 8087823 Elapsed Time: 00:00:05" & @CRLF & _ "222 operating system files processed, 0 broken, totalling 405313 data bytes." & @CRLF & _ "19 UniVerse files processed, 0 corrupted." & @CRLF & _ "36666 UniVerse records processed, 0 corrupted, totalling 7682510 data bytes." & @CRLF & _ "0 extended keys processed, 0 not supported at specified revision level." & @CRLF & _ "" & @CRLF & _ "EndOfUvbackup" $aExtract = _StringBetween($sText, "Total files: ", "EndOfUvbackup") MsgBox(0, "Extract", $aExtract[0])M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Angrysteel Posted January 13, 2010 Author Share Posted January 13, 2010 Angrysteel, If Total files: and EndOfUvbackup appear nowhere else in the text, then _StringBetween should work: expandcollapse popup#Include <String.au3> $sText = _ "Backing up c:/med-edi/ME.BP.O/MENU.DRIVER" & @CRLF & _ "Backing up c:/med-edi/ME.BP.O/MENU.WINDOW" & @CRLF & _ "Backing up c:/med-edi/ME.BP.O/PC" & @CRLF & _ "Backing up c:/med-edi/ME.CF" & @CRLF & _ "Backing up c:/med-edi/ME.CF/.Type1" & @CRLF & _ "Backing up c:/med-edi/ME.CF/01.SND" & @CRLF & _ "Backing up c:/med-edi/ME.CF/DSM01.SND" & @CRLF & _ "Backing up c:/med-edi/ME.CF/EDISTAT.txt" & @CRLF & _ "Backing up c:/med-edi/ME.CF/STO.449200" & @CRLF & _ "WARNING: The magic number of this file is byte-swapped, indicating" & _ "the file did not originate on this platform." & @CRLF & _ "Saving as SYSTEM type file!" & @CRLF & _ "Backing up c:/med-edi/ME.CTL" & @CRLF & _ "Backing up c:/med-edi/ME.POPF" & @CRLF & _ "Backing up c:/med-edi/ME.TPF" & @CRLF & _ "Backing up c:/med-edi/reg" & @CRLF & _ "Backing up c:/med-edi/reg/dump.REG.RTF" & @CRLF & _ "Backing up c:/med-edi/reg/REG.RTF" & @CRLF & _ "Backing up c:/med-edi/TEMP" & @CRLF & _ "Backing up c:/med-edi/USER.MPQ" & @CRLF & _ "Backing up c:/med-edi/USER.MPQ/.Type1" & @CRLF & _ "Backing up c:/med-edi/VOC" & @CRLF & _ "Backing up c:/med-edi/VOCLIB" & @CRLF & _ "" & @CRLF & _ "Total files: 241 Total bytes : 8087823 Elapsed Time: 00:00:05" & @CRLF & _ "222 operating system files processed, 0 broken, totalling 405313 data bytes." & @CRLF & _ "19 UniVerse files processed, 0 corrupted." & @CRLF & _ "36666 UniVerse records processed, 0 corrupted, totalling 7682510 data bytes." & @CRLF & _ "0 extended keys processed, 0 not supported at specified revision level." & @CRLF & _ "" & @CRLF & _ "EndOfUvbackup" $aExtract = _StringBetween($sText, "Total files: ", "EndOfUvbackup") MsgBox(0, "Extract", $aExtract[0]) M23 Wow I was searching the help file and online for a good amount of time and didn't come across that. Thank you!!!! Link to comment Share on other sites More sharing options...
scriptjunkie Posted January 13, 2010 Share Posted January 13, 2010 I would probably useStringRegExp --------------------------------------------------------------------------------Check if a string fits a given regular expression pattern.StringRegExp ( "test", "pattern" [, flag ] [, offset ] ] ) Link to comment Share on other sites More sharing options...
somdcomputerguy Posted January 13, 2010 Share Posted January 13, 2010 (edited) I came up with this, which works as long as it's the last 7 lines that are wanted.. StringBetween, which I eventually would have thought of, is more 'flexible' in that regard.. #include <file.au3> Local $aRecords _FileReadToArray("logfile.txt",$aRecords) $y = $aRecords[0] - 7 #cs For $x = $y To $aRecords[0] ConsoleWrite($aRecords[$x] & @LF) Next #ce _FileWriteFromArray("logfileresult.txt", $aRecords, $y, $aRecords[0]) Run("notepad.exe " & "logfileresult.txt") Edited January 13, 2010 by snowmaker - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. 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