Jump to content

DM TextDump


DreamVB
 Share

Recommended Posts

hi all, this is one of my latest appI been working on today. it allows you to extract text from files and store them in a text file. it very easy to use you just pass a input and output file shown further down. Hope you find it us full.

Comments are welcome as I am sure there maybe better ways to do this.

Main Script

#include <file.au3>

Func ShowError()
    MsgBox(16, "Incorrect Parameters", "Example:" & @CRLF & @ScriptName & " /I InFile.exe /O InFile.exe.txt")
EndFunc   ;==>ShowError

Func DumpText($SrcFile, $DestFile)
    Local $Data
    Local $fp
    Local $Buffer
    Local $sLine
    Local $lines[0]
    Local $i

    ;Open file for reading.
    $fp = FileOpen($SrcFile)
    ;Read file contents
    $Data = FileRead($fp)
    ;Close file
    FileClose($fp)

    ;Split up the file using the regex patten.
    $lines = StringRegExp($Data, "[\s\w\.:\\\@]+", 3, 4)

    ;Loop though the lines skiping spaces and empty lines
    For $i = 0 To UBound($lines) - 1
        $sLine = StringStripWS($lines[$i], BitOR(1, 2))
        If StringLen($sLine) > 2 Then
            $Buffer &= $sLine & @CRLF
        EndIf
    Next

    ;Open the output file
    $fp = FileOpen($DestFile, 2)
    ;Write to the file.
    FileWrite($fp, $Buffer)
    ;Close file
    FileClose($fp)

    ;Clear up
    ReDim $lines[0]
    $Data = ""
    $Buffer = ""
    $sLine = ""
EndFunc   ;==>DumpText

Func Main()
    Local $Cmds
    ;Command line
    $Cmds = $CmdLine;
    ;Check command line parms count
    If UBound($Cmds) <> 5 Then
        ;Show error
        ShowError()
    ElseIf StringUpper($CmdLine[1]) <> "/I" Then
        ;Show error
        ShowError()
    ElseIf StringUpper($CmdLine[3]) <> "/O" Then
        ;Show error
        ShowError()
    ElseIf Not FileExists($CmdLine[2]) Then
        ;Show error
        MsgBox(16, "File Not Found", "Input Filename Was Not Found.")
    Else
        DumpText($CmdLine[2], $CmdLine[4])
    EndIf
EndFunc   ;==>Main

;Main program
Main()
Exit

Example

Using batch file.

REM DUMP TEXT EXAMPLE
@ECHO OFF
txtdump.exe /i c:\out\test.exe /o C:\out\output.txt

On Error Resume Pulling Hair Out.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...