Jump to content

File Read Filtering


Hadez
 Share

Recommended Posts

Thank you all for your help. I managed to solve it with your help, although my method was a little noob like :) It is kind of based on:

Local $avArray[4]

$avArray[0] = ".jpg"
$avArray[1] = ".png"
$avArray[2] = ".gif"
$avArray[3] = ".bmp"
;ect...

$line = FileReadLine($filename)
For $i = 0 to UBound($avArray) - 1
    If StringInStr($line,$avArray[$i]) > 0 Then
        FileDelete($filename)
        Return ;Go back to While 1
    EndIf
Next
;rest of processing

But i cudnt quite work that out, so used a basic version of it:

While 1
    Search()
WEnd

Func Search()
    $chkNewFileLocation = FileFindFirstFile($chkPath & "\*.txt")
    If $chkNewFileLocation = -1 Then
        Sleep(10000)
        Return
    EndIf
    While 1
        $chkNewfile = FileFindNextFile($chkNewFileLocation)
        $chkNewFilePath = $chkPath & $chkNewFile
        $filetypecheck = Fileread($chkNewFilePath)
        $oofiletype = StringRight($filetypecheck, 4)
        If $oofiletype = ".png" Then
            Filedelete($chkNewFilePath)
            Return
            elseif $oofiletype = ".gif" Then
            Filedelete($chkNewFilePath)
            Return
            elseif $oofiletype = ".jpeg" Then
            Filedelete($chkNewFilePath)
            Return
        Endif
        msgbox(0,"Success","This works ok so continue procesing") ; rest of processing follows
        Sleep(10000)
    WEnd
EndFunc

seems like the StringRight solved the problem. Thanks for also explaining Return. The biggest problem for me was to get back to while 1, which return solved. Thanks for all your help ;)

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...