Jump to content

Find lost files


Recommended Posts

Hello i've got a Folder with 20.000 files. There are 4 types of Files *.idy, *.txt,*.pdf and *.rdy . The files are all generated.. and one or two files are missing. No i want to find the missing files.. The way to find the missing files is to check with every name all the 4 file types. For Every Name like "LP200202000013_00005083" exists one file with the ending .pdf .txt .idx and .rdy. The tool now had to check if exists vor every name 4 files. If not list the missing files in a popup message or a logfile.

Can anyone Help me?

German:

Hallo ich brauche ein Tool welches die Vollständigkeit für ein Bestimmten namen überprüft. Ich habe 4 Dateiendungen mit jeweils dem Selben Namen. Ich habe die Endungen *.idy, *.txt,*.pdf und *.rdy. Für jede dieser Endungen gibt es genau den selben Dateinamen, wie z.b. "LP200202000013_00005083". Für diesen Namen exisitiert dann eine Datei mit der Endung pdf idx txt und rdy. Ich muss nun die Files finden die fehlen. Es kann halt sein das eine Datei mit der endung rdy fehlt oder pdf oder txt. Ich muss also nun "nur" prüfen ob es die datei LP200202000013_00005083.pdf und LP200202000013_00005083.rdy und LP200202000013_00005083.txt und LP200202000013_00005083.idx gibt dann zur nächsten datei und dann wieder prüfen ob es davon 4 gibt.

Link to comment
Share on other sites

; Shows the filenames of all files in the current directory, note that "." and ".." are returned.
$search = FileFindFirstFile("*.*")

; Check if the search was successful
If $search = -1 Then
    MsgBox(0, "Error", "No files/directories matched the search pattern")
    Exit
EndIf

While 1
    $file = FileFindNextFile($search)
    If @error Then ExitLoop
    
    $attrib = FileGetAttrib($file)
    If @error Then
        MsgBox(4096, "Error", "Could not obtain attributes.")
        Exit
    Else
        If Not StringInStr($attrib, "D") And $file <> @ScriptName Then
            $name = StringTrimRight($file, 4)
            If Not FileExists($name & ".idy") Then
                MsgBox(48, "Missing file", $name & ".idy")
            EndIf
            If Not FileExists($name & ".txt") Then
                MsgBox(48, "Missing file", $name & ".txt")
            EndIf
            If Not FileExists($name & ".pdf") Then
                MsgBox(48, "Missing file", $name & ".pdf")
            EndIf
            If Not FileExists($name & ".rdy") Then
                MsgBox(48, "Missing file", $name & ".rdy")
            EndIf
        EndIf
    EndIf
WEnd

; Close the search handle
FileClose($search)

MsgBox(64, "", "Ready")

Just a raw start. The missing file is displayed 3 times

Put this script in the directory where your 20.000 files are

Edited by Geert
Link to comment
Share on other sites

#Include<Array.au3>
Dim $Array[1]
$Array[0] = "0"

; Shows the filenames of all files in the current directory, note that "." and ".." are returned.
$search = FileFindFirstFile("*.*")

; Check if the search was successful
If $search = -1 Then
    MsgBox(0, "Error", "No files/directories matched the search pattern")
    Exit
EndIf

While 1
    $file = FileFindNextFile($search)
    If @error Then ExitLoop
    
    $attrib = FileGetAttrib($file)
    If @error Then
        MsgBox(4096, "Error", "Could not obtain attributes.")
        Exit
    Else
        If Not StringInStr($attrib, "D") And $file <> @ScriptName Then
            $name = StringTrimRight($file, 4)
            
            $Pos = _ArraySearch ($Array, $name)
            Select
                Case $Pos = -1
                ; MsgBox(0, "Not Found", '"' & $name & '" was not found in the array.')
                    If Not FileExists($name & ".idy") Then
                        MsgBox(48, "Missing file", $name & ".idy")
                    EndIf
                    If Not FileExists($name & ".txt") Then
                        MsgBox(48, "Missing file", $name & ".txt")
                    EndIf
                    If Not FileExists($name & ".pdf") Then
                        MsgBox(48, "Missing file", $name & ".pdf")
                    EndIf
                    If Not FileExists($name & ".rdy") Then
                        MsgBox(48, "Missing file", $name & ".rdy")
                    EndIf
                    _ArrayAdd($Array, $name)
                Case Else
                ; MsgBox(0, "Found", '"' & $name & '" was found in the array at pos ' & $Pos & ".")
            EndSelect
        EndIf
    EndIf
WEnd

; Close the search handle
FileClose($search)

MsgBox(64, "", "Ready")

Use the latest Beta for the _ArraySearch function

Edited by Geert
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...