Doppelte Dateien finden und nach abfrage weiterverarbeiten

  • Hallo !

    Ich habe folgendes problem:

    nachdem ich alle doppelten dateien erkannt habe versuche ich sie auszuwerten und weiter zu verarbeiten

    Nur irgendwie bekomm ich immer die gleichen array Fehler ... arrays scheinen wohl nicht so mein Ding zu sein :D

    ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.:

    [autoit]

    dim $hFilesFolders[120]
    dim $iCol, $ext , $Col
    Dim $path[100][3]
    dim $out[100]

    [/autoit][autoit][/autoit][autoit]

    ; file mask to search for
    $hFilesFolders = _FileListToArrayEx('h:', '*.zip')

    [/autoit][autoit][/autoit][autoit][/autoit][autoit]

    for $i = 1 to $hFilesFolders[0]
    _PathSplit($hFilesFolders[$i], $path[$i][0],$path[$i][1], $path[$i][2],$ext) ;Pfade aufsplitten
    _ArrayInsert($out, $i,$path[$i][2]) ;$path[][2] spiegeln
    Next
    _ArraySort($path,0,0,0,2);sortieren
    _arraysort($out,0,0,0,0);sortieren
    _Array2DEmptyDel($path, $Col=1);leere Zeilen löschen
    _Array2DEmptyDel($out, $Col=0);leere Zeilen löschen

    [/autoit][autoit][/autoit][autoit][/autoit][autoit]

    for $i = 1 to $out[0]
    for $x = 1 to $path[0][2]
    if $out[$i] = $path[$x-1][2] Then;überprüfen ob Dateiname gleich ist
    MsgBox(0,"title",$out[$i] & @CRLF & $path[$x-1][2]);gleiche Dateinamen anzeigen
    EndIf
    Next
    Next

    [/autoit][autoit][/autoit][autoit]

    ; datum der doppelten Dateien vergleichen
    ; ältere datei löschen

    [/autoit]


    hier die suchfunktion die ich benutzte

    Spoiler anzeigen
    [autoit]

    ;==================================================================================================
    ; Function Name: _Array2DSortFree($ARRAY, $sCOL_ASC [, $NUM=False])
    ; Description:: Sortierung von 1D/2D-Arrays nach freier Wahl
    ; 1D Sortierung Auf- oder Absteigend
    ; 2D mehrstufige Sortierung, Reihenfolge und Sortier-
    ; richtung (je Spalte) frei wählbar
    ; auch einzelne Spalte sortierbar
    ; Parameter(s): $ARRAY Das zu sortierende Array
    ; $sCOL_ASC String mit Sortierangaben "Spalte|Richtung [, Spalte|Richtung]"
    ; zu sortierende Spalte (0-Index)|Richtung (0-Asc, 1-Desc)
    ; z.B. Spalte 2 aufsteigend und in 2 absteigend Spalte 1
    ; _Array2DSortFree($ar2Sort, '1|0,0|1')
    ; optional $NUM "False" sortiert alphabetisch (Standard), "True" sortiert numerisch
    ; Return Value(s): Erfolg 0
    ; Fehler 1 Set Error 1 $ARRAY ist kein Array
    ; 2 1D-Array, aber Spaltenangabe für 2D
    ; 3 SQL-Fehler
    ; 4 Angaben für Spalte|Sortierrichtung fehlerhaft
    ; Requirements: #include <SQLite.au3>
    ; #include <SQLite.dll.au3>
    ; #include <Array.au3>
    ; Note: Es ist dringend erforderlich, die SQLite-Includes am Beginn des aufrufenden
    ; Skriptes auszuführen. Anderenfalls schlägt die Initialisierung der SQLite.dll
    ; durch _SQLite_Startup() fehl.
    ; Version: 3.3.0.0
    ; Author(s): BugFix ([email='bugfix@autoit.de'][/email])
    ;==================================================================================================

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _FileListToArrayEx($s_path, $s_mask, $i_flag = 0, $s_exclude = -1, $f_recurse = True, $f_full_path = True)

    [/autoit] [autoit][/autoit] [autoit]

    If FileExists($s_path) = 0 Then Return SetError(1, 1, 0)

    [/autoit] [autoit][/autoit] [autoit]

    ; Strip trailing backslash, and add one after to make sure there's only one
    $s_path = StringRegExpReplace($s_path, "[\\/]+\z", "") & "\"

    [/autoit] [autoit][/autoit] [autoit]

    ; Set all defaults
    If $s_mask = -1 Or $s_mask = Default Then $s_mask = "*.*"
    If $i_flag = -1 Or $i_flag = Default Then $i_flag = 0
    If $s_exclude = -1 Or $s_exclude = Default Then $s_exclude = ""

    [/autoit] [autoit][/autoit] [autoit]

    ; Look for bad chars
    If StringRegExp($s_mask, "[\\/:><\|]") Or StringRegExp($s_exclude, "[\\/:><\|]") Then
    Return SetError(2, 2, 0)
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    ; Strip leading spaces between semi colon delimiter
    $s_mask = StringRegExpReplace($s_mask, "\s*;\s*", ";")
    If $s_exclude Then $s_exclude = StringRegExpReplace($s_exclude, "\s*;\s*", ";")

    [/autoit] [autoit][/autoit] [autoit]

    ; Confirm mask has something in it
    If StringStripWS($s_mask, 8) = "" Then Return SetError(2, 2, 0)
    If $i_flag < 0 Or $i_flag > 2 Then Return SetError(3, 3, 0)

    [/autoit] [autoit][/autoit] [autoit]

    ; Validate and create path + mask params
    Local $a_split = StringSplit($s_mask, ";"), $s_hold_split = ""
    For $i = 1 To $a_split[0]
    If StringStripWS($a_split[$i], 8) = "" Then ContinueLoop
    If StringRegExp($a_split[$i], "^\..*?\..*?\z") Then
    $a_split[$i] &= "*" & $a_split[$i]
    EndIf
    $s_hold_split &= '"' & $s_path & $a_split[$i] & '" '
    Next
    $s_hold_split = StringTrimRight($s_hold_split, 1)
    If $s_hold_split = "" Then $s_hold_split = '"' & $s_path & '*.*"'

    [/autoit] [autoit][/autoit] [autoit]

    Local $i_pid, $s_stdout, $s_hold_out, $s_dir_file_only = "", $s_recurse = "/s "
    If $i_flag = 1 Then $s_dir_file_only = ":-d"
    If $i_flag = 2 Then $s_dir_file_only = ":d"
    If Not $f_recurse Then $s_recurse = ""

    [/autoit] [autoit][/autoit] [autoit]

    Local $i_buffer, $t_input, $t_output, $s_hold_binary

    [/autoit] [autoit][/autoit] [autoit]

    $i_pid = Run(@ComSpec & " /u /c dir /b " & _
    $s_recurse & "/a" & $s_dir_file_only & " " & _
    $s_hold_split, "", @SW_HIDE, 4 + 2)

    [/autoit] [autoit][/autoit] [autoit]

    ; Collect data from std i/o stream
    While 1
    $s_stdout = StdoutRead($i_pid, False, True)
    If @error Then ExitLoop
    $i_buffer = BinaryLen($s_stdout)
    $t_input = DllStructCreate("byte[" & $i_buffer & "]")
    $t_output = DllStructCreate("char[" & $i_buffer & "]")

    [/autoit] [autoit][/autoit] [autoit]

    DllStructSetData($t_input, 1, $s_stdout)
    DllCall("kernel32.dll", "int", "WideCharToMultiByte", _
    "int", 0, "int", 0, "ptr", DllStructGetPtr($t_input), _
    "int", $i_buffer / 2, "ptr", DllStructGetPtr($t_output), _
    "int", $i_buffer, "int", 0, "int", 0)

    [/autoit] [autoit][/autoit] [autoit]

    $s_hold_out &= StringRegExpReplace(DllStructGetData($t_output, 1), "(?i)(?:\A|\v)(?:(0+\v+)|(0+))|(\v*0+\z)", "")
    $t_input = 0
    $t_output = 0
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    ; Replace any extending verticle spaces from the end of the string
    $s_hold_out = StringRegExpReplace($s_hold_out, "\v+\z", "")
    If Not $s_hold_out Then Return SetError(5, 5, 0)

    [/autoit] [autoit][/autoit] [autoit]

    ; Parse data and find matches based on flags
    Local $a_fsplit = StringSplit(StringStripCR($s_hold_out), @LF), $s_hold_ret
    $s_hold_out = ""

    [/autoit] [autoit][/autoit] [autoit]

    If $s_exclude Then $s_exclude = StringReplace(StringReplace($s_exclude, "*", ".*?"), ";", "|")
    Local $i_path_len = BinaryLen($s_path)

    [/autoit] [autoit][/autoit] [autoit]

    For $i = 1 To $a_fsplit[0]
    If $s_exclude And StringRegExp(StringRegExpReplace( _
    $a_fsplit[$i], "(.*?[\\/]+)*(.*?\z)", "\2"), "(?i)" & $s_exclude) Then ContinueLoop
    If StringRegExp($a_fsplit[$i], "^\w:[\\/]+") = 0 Then $a_fsplit[$i] = $s_path & $a_fsplit[$i]
    If $f_full_path Then
    $s_hold_ret &= $a_fsplit[$i] & Chr(1)
    Else
    $s_hold_ret &= StringTrimLeft($a_fsplit[$i], $i_path_len) & Chr(1)
    EndIf
    Next

    [/autoit] [autoit][/autoit] [autoit]

    $s_hold_ret = StringTrimRight($s_hold_ret, 1)
    If $s_hold_ret = "" Then Return SetError(6, 6, 0)

    [/autoit] [autoit][/autoit] [autoit]

    Return StringSplit($s_hold_ret, Chr(1))
    EndFunc

    [/autoit]

    Einmal editiert, zuletzt von baar (11. August 2009 um 19:21)

    • Offizieller Beitrag

    Was hällst du davon ein Script zu posten was man auch ausführen und testen kann. Ist das so schwer oder das Script so geheim? Du benutz die Function _Array2DEmptyDel die aber in deinem Code nicht enthalten ist. Mach es uns doch nicht so schwer zu helfen. Sollen wir die Function erst suchen und aus deinen Codeteilen ein lauffähiges Script basteln ?

  • natürlich :)

    entschuldige einfach nicht dran gedacht !

    Spoiler anzeigen
    [autoit]

    #include<array.au3>
    #include<file.au3>
    ;===============================================================================
    ;
    ; Description: lists all or preferred files and or folders in a specified path (Similar to using Dir with the /B Switch)
    ; Syntax: _FileListToArrayEx($sPath, $sFilter = '*.*', $iFlag = 0, $sExclude = '')
    ; Parameter(s): $sPath = Path to generate filelist for
    ; $sFilter = The filter to use. Search the Autoit3 manual for the word "WildCards" For details, support now for multiple searches
    ; Example *.exe; *.txt will find all .exe and .txt files
    ; $iFlag = determines weather to return file or folders or both.
    ; $sExclude = exclude a file from the list by all or part of its name
    ; Example: Unins* will remove all files/folders that start with Unins
    ; $iFlag=0(Default) Return both files and folders
    ; $iFlag=1 Return files Only
    ; $iFlag=2 Return Folders Only
    ;
    ; Requirement(s): None
    ; Return Value(s): On Success - Returns an array containing the list of files and folders in the specified path
    ; On Failure - Returns the an empty string "" if no files are found and sets @Error on errors
    ; @Error or @extended = 1 Path not found or invalid
    ; @Error or @extended = 2 Invalid $sFilter or Invalid $sExclude
    ; @Error or @extended = 3 Invalid $iFlag
    ; @Error or @extended = 4 No File(s) Found
    ;
    ; Author(s): SmOke_N
    ; Note(s): The array returned is one-dimensional and is made up as follows:
    ; $array[0] = Number of Files\Folders returned
    ; $array[1] = 1st File\Folder
    ; $array[2] = 2nd File\Folder
    ; $array[3] = 3rd File\Folder
    ; $array[n] = nth File\Folder
    ;
    ; All files are written to a "reserved" .tmp file (Thanks to gafrost) for the example
    ; The Reserved file is then read into an array, then deleted
    ;===============================================================================

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    dim $hFilesFolders[120]
    dim $iCol, $ext , $Col
    Dim $path[100][3]
    dim $out[100]

    [/autoit] [autoit][/autoit] [autoit]

    ; file mask to search for
    $hFilesFolders = _FileListToArrayEx('h:', '*.zip')

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    for $i = 1 to $hFilesFolders[0]
    _PathSplit($hFilesFolders[$i], $path[$i][0],$path[$i][1], $path[$i][2],$ext) ;Pfade aufsplitten
    _ArrayInsert($out, $i,$path[$i][2]) ;$path[][2] spiegeln
    Next
    _ArraySort($path,0,0,0,2) ;sortieren
    _arraysort($out,0,0,0,0) ;sortieren
    _Array2DEmptyDel($path, $Col=1) ;leere Zeilen löschen
    _Array2DEmptyDel($out, $Col=0) ;leere Zeilen löschen
    _ArrayDisplay($path)

    [/autoit] [autoit][/autoit] [autoit]

    for $i = 1 to $out[0]
    for $x = 1 to $path[0][2]
    if $out[$i] = $path[$x-1][2] Then ;überprüfen ob Dateiname gleich ist
    MsgBox(0,"title",$out[$i] & @CRLF & $path[$x-1][2]) ;gleiche Dateinamen anzeigen
    EndIf
    Next
    Next

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    ;==================================================================================================
    ; Function Name: _Array2DSortFree($ARRAY, $sCOL_ASC [, $NUM=False])
    ; Description:: Sortierung von 1D/2D-Arrays nach freier Wahl
    ; 1D Sortierung Auf- oder Absteigend
    ; 2D mehrstufige Sortierung, Reihenfolge und Sortier-
    ; richtung (je Spalte) frei wählbar
    ; auch einzelne Spalte sortierbar
    ; Parameter(s): $ARRAY Das zu sortierende Array
    ; $sCOL_ASC String mit Sortierangaben "Spalte|Richtung [, Spalte|Richtung]"
    ; zu sortierende Spalte (0-Index)|Richtung (0-Asc, 1-Desc)
    ; z.B. Spalte 2 aufsteigend und in 2 absteigend Spalte 1
    ; _Array2DSortFree($ar2Sort, '1|0,0|1')
    ; optional $NUM "False" sortiert alphabetisch (Standard), "True" sortiert numerisch
    ; Return Value(s): Erfolg 0
    ; Fehler 1 Set Error 1 $ARRAY ist kein Array
    ; 2 1D-Array, aber Spaltenangabe für 2D
    ; 3 SQL-Fehler
    ; 4 Angaben für Spalte|Sortierrichtung fehlerhaft
    ; Requirements: #include <SQLite.au3>
    ; #include <SQLite.dll.au3>
    ; #include <Array.au3>
    ; Note: Es ist dringend erforderlich, die SQLite-Includes am Beginn des aufrufenden
    ; Skriptes auszuführen. Anderenfalls schlägt die Initialisierung der SQLite.dll
    ; durch _SQLite_Startup() fehl.
    ; Version: 3.3.0.0
    ; Author(s): BugFix ([email='bugfix@autoit.de'][/email])
    ;==================================================================================================

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _FileListToArrayEx($s_path, $s_mask, $i_flag = 0, $s_exclude = -1, $f_recurse = True, $f_full_path = True)

    [/autoit] [autoit][/autoit] [autoit]

    If FileExists($s_path) = 0 Then Return SetError(1, 1, 0)

    [/autoit] [autoit][/autoit] [autoit]

    ; Strip trailing backslash, and add one after to make sure there's only one
    $s_path = StringRegExpReplace($s_path, "[\\/]+\z", "") & "\"

    [/autoit] [autoit][/autoit] [autoit]

    ; Set all defaults
    If $s_mask = -1 Or $s_mask = Default Then $s_mask = "*.*"
    If $i_flag = -1 Or $i_flag = Default Then $i_flag = 0
    If $s_exclude = -1 Or $s_exclude = Default Then $s_exclude = ""

    [/autoit] [autoit][/autoit] [autoit]

    ; Look for bad chars
    If StringRegExp($s_mask, "[\\/:><\|]") Or StringRegExp($s_exclude, "[\\/:><\|]") Then
    Return SetError(2, 2, 0)
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    ; Strip leading spaces between semi colon delimiter
    $s_mask = StringRegExpReplace($s_mask, "\s*;\s*", ";")
    If $s_exclude Then $s_exclude = StringRegExpReplace($s_exclude, "\s*;\s*", ";")

    [/autoit] [autoit][/autoit] [autoit]

    ; Confirm mask has something in it
    If StringStripWS($s_mask, 8) = "" Then Return SetError(2, 2, 0)
    If $i_flag < 0 Or $i_flag > 2 Then Return SetError(3, 3, 0)

    [/autoit] [autoit][/autoit] [autoit]

    ; Validate and create path + mask params
    Local $a_split = StringSplit($s_mask, ";"), $s_hold_split = ""
    For $i = 1 To $a_split[0]
    If StringStripWS($a_split[$i], 8) = "" Then ContinueLoop
    If StringRegExp($a_split[$i], "^\..*?\..*?\z") Then
    $a_split[$i] &= "*" & $a_split[$i]
    EndIf
    $s_hold_split &= '"' & $s_path & $a_split[$i] & '" '
    Next
    $s_hold_split = StringTrimRight($s_hold_split, 1)
    If $s_hold_split = "" Then $s_hold_split = '"' & $s_path & '*.*"'

    [/autoit] [autoit][/autoit] [autoit]

    Local $i_pid, $s_stdout, $s_hold_out, $s_dir_file_only = "", $s_recurse = "/s "
    If $i_flag = 1 Then $s_dir_file_only = ":-d"
    If $i_flag = 2 Then $s_dir_file_only = ":d"
    If Not $f_recurse Then $s_recurse = ""

    [/autoit] [autoit][/autoit] [autoit]

    Local $i_buffer, $t_input, $t_output, $s_hold_binary

    [/autoit] [autoit][/autoit] [autoit]

    $i_pid = Run(@ComSpec & " /u /c dir /b " & _
    $s_recurse & "/a" & $s_dir_file_only & " " & _
    $s_hold_split, "", @SW_HIDE, 4 + 2)

    [/autoit] [autoit][/autoit] [autoit]

    ; Collect data from std i/o stream
    While 1
    $s_stdout = StdoutRead($i_pid, False, True)
    If @error Then ExitLoop
    $i_buffer = BinaryLen($s_stdout)
    $t_input = DllStructCreate("byte[" & $i_buffer & "]")
    $t_output = DllStructCreate("char[" & $i_buffer & "]")

    [/autoit] [autoit][/autoit] [autoit]

    DllStructSetData($t_input, 1, $s_stdout)
    DllCall("kernel32.dll", "int", "WideCharToMultiByte", _
    "int", 0, "int", 0, "ptr", DllStructGetPtr($t_input), _
    "int", $i_buffer / 2, "ptr", DllStructGetPtr($t_output), _
    "int", $i_buffer, "int", 0, "int", 0)

    [/autoit] [autoit][/autoit] [autoit]

    $s_hold_out &= StringRegExpReplace(DllStructGetData($t_output, 1), "(?i)(?:\A|\v)(?:(0+\v+)|(0+))|(\v*0+\z)", "")
    $t_input = 0
    $t_output = 0
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    ; Replace any extending verticle spaces from the end of the string
    $s_hold_out = StringRegExpReplace($s_hold_out, "\v+\z", "")
    If Not $s_hold_out Then Return SetError(5, 5, 0)

    [/autoit] [autoit][/autoit] [autoit]

    ; Parse data and find matches based on flags
    Local $a_fsplit = StringSplit(StringStripCR($s_hold_out), @LF), $s_hold_ret
    $s_hold_out = ""

    [/autoit] [autoit][/autoit] [autoit]

    If $s_exclude Then $s_exclude = StringReplace(StringReplace($s_exclude, "*", ".*?"), ";", "|")
    Local $i_path_len = BinaryLen($s_path)

    [/autoit] [autoit][/autoit] [autoit]

    For $i = 1 To $a_fsplit[0]
    If $s_exclude And StringRegExp(StringRegExpReplace( _
    $a_fsplit[$i], "(.*?[\\/]+)*(.*?\z)", "\2"), "(?i)" & $s_exclude) Then ContinueLoop
    If StringRegExp($a_fsplit[$i], "^\w:[\\/]+") = 0 Then $a_fsplit[$i] = $s_path & $a_fsplit[$i]
    If $f_full_path Then
    $s_hold_ret &= $a_fsplit[$i] & Chr(1)
    Else
    $s_hold_ret &= StringTrimLeft($a_fsplit[$i], $i_path_len) & Chr(1)
    EndIf
    Next

    [/autoit] [autoit][/autoit] [autoit]

    $s_hold_ret = StringTrimRight($s_hold_ret, 1)
    If $s_hold_ret = "" Then Return SetError(6, 6, 0)

    [/autoit] [autoit][/autoit] [autoit]

    Return StringSplit($s_hold_ret, Chr(1))
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    ;----------------------------------------------------------------------------------------------------------------------
    ; Function _Array2DEmptyDel(ByRef $avArray [, $Col=0])
    ;
    ; Description Delete empty Array elements
    ; Delete all emty Rows or all empty Columns
    ; Works also with 1D-Array (only Rows)
    ;
    ; Parameter $avArray Given Array
    ; optional $Col set 1 to delete empty Columns; default is 0 to delete empty Rows
    ;
    ; Return Succes -1 ByRef the given Array without empty Elements, resized
    ; Failure 0 and set @error = 1
    ;
    ; Author BugFix ([email='bugfix@autoit.de'][/email])
    ;----------------------------------------------------------------------------------------------------------------------
    Func _Array2DEmptyDel(ByRef $avArray, $Col=0)
    If ( Not IsArray($avArray) ) Then
    SetError(1)
    Return 0
    EndIf
    Local $i, $k, $notEmpty
    Local $UBound2nd = UBound($avArray,2)
    If @error = 2 Then
    Local $arTMP[1]
    For $i = 0 To UBound($avArray)-1
    If StringLen($avArray[$i] > 0) Then
    If StringLen($arTMP[UBound($arTMP)-1]) = 0 Then
    $arTMP[UBound($arTMP)-1] = $avArray[$i]
    Else
    ReDim $arTMP[UBound($arTMP)+1]
    $arTMP[UBound($arTMP)-1] = $avArray[$i]
    EndIf
    EndIf
    Next
    Else
    If $Col = 0 Then
    Local $arTMP[1][$UBound2nd], $val, $len
    For $i = 0 To UBound($avArray)-1
    $val = ''
    For $k = 0 To $UBound2nd-1
    $val &= $avArray[$i][$k]
    Next
    If StringLen($val) > 0 Then
    $len = 0
    For $k = 0 To UBound($arTMP,2)-1
    $len &= StringLen($arTMP[UBound($arTMP)-1][$k])
    Next
    If $len = 0 Then
    For $k = 0 To $UBound2nd-1
    $arTMP[UBound($arTMP)-1][$k] = $avArray[$i][$k]
    Next
    Else
    ReDim $arTMP[UBound($arTMP)+1][$UBound2nd]
    For $k = 0 To $UBound2nd-1
    $arTMP[UBound($arTMP)-1][$k] = $avArray[$i][$k]
    Next
    EndIf
    EndIf
    Next
    Else
    Local $arTMP[UBound($avArray)][1], $val, $len
    For $k = 0 To $UBound2nd-1
    $val = ''
    $notEmpty = 0
    For $i = 0 To UBound($avArray)-1
    $val &= $avArray[$i][$k]
    If StringLen($val) > 0 Then
    $notEmpty = 1
    ExitLoop
    EndIf
    Next
    If $notEmpty = 1 Then
    $len = 0
    For $i = 0 To UBound($arTMP)-1
    $len &= StringLen($arTMP[$i][UBound($arTMP,2)-1])
    Next
    If $len = 0 Then
    For $i = 0 To UBound($avArray)-1
    $arTMP[$i][0] = $avArray[$i][$k]
    Next
    Else
    ReDim $arTMP[UBound($avArray)][UBound($arTMP,2)+1]
    For $i = 0 To UBound($avArray)-1
    $arTMP[$i][UBound($arTMP,2)-1] = $avArray[$i][$k]
    Next
    EndIf
    EndIf
    Next
    EndIf
    EndIf
    $avArray = $arTMP
    Return -1
    EndFunc ;==>_Array2DEmptyDel

    [/autoit]
    • Offizieller Beitrag

    Ich frag mich wie oft man dir bei dem Thema helfen soll?
    Oscar hat dir doch schon die Lösung programmiert . Da dir die Lösung zu langsam schein probier mal das aus :

    Spoiler anzeigen
    [autoit]

    #cs **************************************************************************

    [/autoit] [autoit][/autoit] [autoit]

    Array sortieren und doppelte Einträge finden

    [/autoit] [autoit][/autoit] [autoit]

    http://www.autoit.de/index.php?page…7377#post107377

    [/autoit] [autoit][/autoit] [autoit]

    #ce **************************************************************************

    [/autoit] [autoit][/autoit] [autoit]

    $sSearchPath = 'h:\' ; Pfad der durchsucht werden soll (rekursiv)
    $sSearchPattern = '.+\.zip' ; RegExp-Pattern
    $sSavePath = @ScriptDir & '\Doppelte.txt' ; Datei (inkl. Pfad), in der die doppelten gespeichert werden

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    ToolTip('Bitte warten! Verzeichnis wird eingelesen!', @DesktopWidth/2-100, 80, 'Double-Finder', 1, 7)
    Global $aFiles = _FileListToArrayEx('c:', '*.zip')
    Global $sExists = '|', $sFilename = '', $sDouble = '', $iPos = 0
    ToolTip($aFiles[0] & ' Dateien gefunden' & @CRLF & 'Bitte warten! Doppelte werden gesucht!', @DesktopWidth/2-100, 100, 'Double-Finder', 1, 7)
    For $i = 1 To $aFiles[0]
    $sFilename = StringRegExpReplace($aFiles[$i], '.+\\(.+)', '$1')
    $iPos = StringInStr($sExists, '\' & $sFilename)
    If $iPos Then
    $iStart = StringInStr($sExists, '|', 0, -1, $iPos)
    $iEnd = StringInStr($sExists, '|', 0, 1, $iPos)
    $sDouble &= StringMid($sExists, $iStart, $iEnd - $iStart) & '|'
    $sDouble &= $aFiles[$i] & '|'
    EndIf
    $sExists &= $aFiles[$i] & '|'
    Next
    $hFile = FileOpen($sSavePath, 2)
    FileWrite($hFile, StringReplace($sDouble, '|', @CRLF))
    FileClose($hFile)
    ShellExecute('notepad.exe', $sSavePath)
    ToolTip('Fertig! Datei erstellt!', @DesktopWidth/2-100, 120, 'Double-Finder', 1, 7)
    Sleep(3000)
    Exit
    Func _FileListToArrayEx($s_path, $s_mask, $i_flag = 0, $s_exclude = -1, $f_recurse = True, $f_full_path = True)

    [/autoit] [autoit][/autoit] [autoit]

    If FileExists($s_path) = 0 Then Return SetError(1, 1, 0)

    [/autoit] [autoit][/autoit] [autoit]

    ; Strip trailing backslash, and add one after to make sure there's only one
    $s_path = StringRegExpReplace($s_path, "[\\/]+\z", "") & "\"

    [/autoit] [autoit][/autoit] [autoit]

    ; Set all defaults
    If $s_mask = -1 Or $s_mask = Default Then $s_mask = "*.*"
    If $i_flag = -1 Or $i_flag = Default Then $i_flag = 0
    If $s_exclude = -1 Or $s_exclude = Default Then $s_exclude = ""

    [/autoit] [autoit][/autoit] [autoit]

    ; Look for bad chars
    If StringRegExp($s_mask, "[\\/:><\|]") Or StringRegExp($s_exclude, "[\\/:><\|]") Then
    Return SetError(2, 2, 0)
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    ; Strip leading spaces between semi colon delimiter
    $s_mask = StringRegExpReplace($s_mask, "\s*;\s*", ";")
    If $s_exclude Then $s_exclude = StringRegExpReplace($s_exclude, "\s*;\s*", ";")

    [/autoit] [autoit][/autoit] [autoit]

    ; Confirm mask has something in it
    If StringStripWS($s_mask, 8) = "" Then Return SetError(2, 2, 0)
    If $i_flag < 0 Or $i_flag > 2 Then Return SetError(3, 3, 0)

    [/autoit] [autoit][/autoit] [autoit]

    ; Validate and create path + mask params
    Local $a_split = StringSplit($s_mask, ";"), $s_hold_split = ""
    For $i = 1 To $a_split[0]
    If StringStripWS($a_split[$i], 8) = "" Then ContinueLoop
    If StringRegExp($a_split[$i], "^\..*?\..*?\z") Then
    $a_split[$i] &= "*" & $a_split[$i]
    EndIf
    $s_hold_split &= '"' & $s_path & $a_split[$i] & '" '
    Next
    $s_hold_split = StringTrimRight($s_hold_split, 1)
    If $s_hold_split = "" Then $s_hold_split = '"' & $s_path & '*.*"'

    [/autoit] [autoit][/autoit] [autoit]

    Local $i_pid, $s_stdout, $s_hold_out, $s_dir_file_only = "", $s_recurse = "/s "
    If $i_flag = 1 Then $s_dir_file_only = ":-d"
    If $i_flag = 2 Then $s_dir_file_only = ":d"
    If Not $f_recurse Then $s_recurse = ""

    [/autoit] [autoit][/autoit] [autoit]

    Local $i_buffer, $t_input, $t_output, $s_hold_binary

    [/autoit] [autoit][/autoit] [autoit]

    $i_pid = Run(@ComSpec & " /u /c dir /b " & _
    $s_recurse & "/a" & $s_dir_file_only & " " & _
    $s_hold_split, "", @SW_HIDE, 4 + 2)

    [/autoit] [autoit][/autoit] [autoit]

    ; Collect data from std i/o stream
    While 1
    $s_stdout = StdoutRead($i_pid, False, True)
    If @error Then ExitLoop
    $i_buffer = BinaryLen($s_stdout)
    $t_input = DllStructCreate("byte[" & $i_buffer & "]")
    $t_output = DllStructCreate("char[" & $i_buffer & "]")

    [/autoit] [autoit][/autoit] [autoit]

    DllStructSetData($t_input, 1, $s_stdout)
    DllCall("kernel32.dll", "int", "WideCharToMultiByte", _
    "int", 0, "int", 0, "ptr", DllStructGetPtr($t_input), _
    "int", $i_buffer / 2, "ptr", DllStructGetPtr($t_output), _
    "int", $i_buffer, "int", 0, "int", 0)

    [/autoit] [autoit][/autoit] [autoit]

    $s_hold_out &= StringRegExpReplace(DllStructGetData($t_output, 1), "(?i)(?:\A|\v)(?:(0+\v+)|(0+))|(\v*0+\z)", "")
    $t_input = 0
    $t_output = 0
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    ; Replace any extending verticle spaces from the end of the string
    $s_hold_out = StringRegExpReplace($s_hold_out, "\v+\z", "")
    If Not $s_hold_out Then Return SetError(5, 5, 0)

    [/autoit] [autoit][/autoit] [autoit]

    ; Parse data and find matches based on flags
    Local $a_fsplit = StringSplit(StringStripCR($s_hold_out), @LF), $s_hold_ret
    $s_hold_out = ""

    [/autoit] [autoit][/autoit] [autoit]

    If $s_exclude Then $s_exclude = StringReplace(StringReplace($s_exclude, "*", ".*?"), ";", "|")
    Local $i_path_len = BinaryLen($s_path)

    [/autoit] [autoit][/autoit] [autoit]

    For $i = 1 To $a_fsplit[0]
    If $s_exclude And StringRegExp(StringRegExpReplace( _
    $a_fsplit[$i], "(.*?[\\/]+)*(.*?\z)", "\2"), "(?i)" & $s_exclude) Then ContinueLoop
    If StringRegExp($a_fsplit[$i], "^\w:[\\/]+") = 0 Then $a_fsplit[$i] = $s_path & $a_fsplit[$i]
    If $f_full_path Then
    $s_hold_ret &= $a_fsplit[$i] & Chr(1)
    Else
    $s_hold_ret &= StringTrimLeft($a_fsplit[$i], $i_path_len) & Chr(1)
    EndIf
    Next

    [/autoit] [autoit][/autoit] [autoit]

    $s_hold_ret = StringTrimRight($s_hold_ret, 1)
    If $s_hold_ret = "" Then Return SetError(6, 6, 0)

    [/autoit] [autoit][/autoit] [autoit]

    Return StringSplit($s_hold_ret, Chr(1))
    EndFunc ;==>_FileListToArrayEx

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    ;

    [/autoit]
  • Ich glaub ich habe mich unklar ausgedrückt !
    Entschuldige Raupi.

    Ich hatte einfach nicht verstanden wieso meine Schleife nicht funktioniert hat und immer
    range exceeded kam ...

    Mitlerweile bin ich einen Schritt weiter gekommen und habe jetzt ein anderes Problem !
    Nachdem ich alle Doppelten Dateien ausgewertet habe versuche ich mit iniread einen wert zu bekommen
    und diesen dann zu vergleichen !

    Jetzt mein Problem :

    In dem Moment wenn ich den Wert aus der INI mit < vergleiche kommt eine total falsche ausgabe raus.

    [autoit]

    for $i = 1 to $ini[0]
    $number1 = IniRead($ini[$i],"test","test1","")
    $number2 = IniRead($ini[$i+1],"test","test1","")
    if $number1 < $number2 Then
    msgbox(0,"","ist" & $number1 & "kleiner als" & $number2 & '?')
    EndIf
    if $number1 > $number2 Then
    MsgBox(0,'', $number1 & ' bigger than ' & $number2)
    EndIf
    Next

    [/autoit]

    Wenn ich aber die Ini Werte Manuell setzte also

    [autoit]

    for $i = 1 to $ini[0]
    $number1 = 1
    $number2 = 2
    if $number1 < $number2 Then
    msgbox(0,"","ist" & $number1 & "kleiner als" & $number2 & '?')
    EndIf
    if $number1 > $number2 Then
    MsgBox(0,'', $number1 & ' bigger than ' & $number2)
    EndIf
    Next

    [/autoit]

    Dann funktioniert alles !
    Habe auch schon die Werte aus der Schleife überprüft da wird das > oder < zeichen einfach ignoriert :(

    Würde mich über Hilfe freuen.

    Einmal editiert, zuletzt von baar (11. August 2009 um 19:14)

    • Offizieller Beitrag

    Wenn Du Zahlen vergleichen willst, musst Du das AutoIt mitteilen, ansonsten werden die Werte als String interpretiert:

    Spoiler anzeigen
    [autoit]


    For $i = 1 To $ini[0]
    $number1 = Number(IniRead($nvs[$i], "test", "test1", ""))
    $number2 = Number(IniRead($nvs[$i + 1], "test", "test1", ""))
    If $number1 < $number2 Then
    MsgBox(0, "", "ist" & $number1 & "kleiner als" & $number2 & '?')
    EndIf
    If $number1 > $number2 Then
    MsgBox(0, '', $number1 & ' bigger than ' & $number2)
    EndIf
    Next

    [/autoit]