Func _ArrayDeleteEmpty(ByRef $ARRAY) If Not IsArray($ARRAY) Then Return 0 Local $arTMP[1] For $i = 0 To UBound($ARRAY) - 1 If $ARRAY[$i] <> '' Then If $arTMP[0] = '' Then $arTMP[0] = $ARRAY[$i] Else ReDim $arTMP[UBound($arTMP) + 1] $arTMP[UBound($arTMP) - 1] = $ARRAY[$i] EndIf EndIf Next $ARRAY = $arTMP EndFunc ;==>_ArrayDeleteEmpty Func _SearchDoubles(ByRef $sSearchPath, ByRef $sSearchPattern) ToolTip('Bitte warten...', Default, Default, 'Doppelte Dateien werden gesucht und eingelesen!', 1, 3) Local $SearchPattern Local $sSavePath = @ScriptDir & '\Doppelte.txt' If $sSearchPath = "" Or $sSearchPath = "Search Path" Then MsgBox(16, "", "No Path") Exit EndIf Switch $sSearchPattern Case "Text-Files" ConsoleWrite("@@ (001) :(" & @MIN & ':' & @SEC & ") Switch, $sSearchPattern" & " = " & " Text-Files" & @CR) $sSearchPattern = '*.txt' Case "Log-Files" ConsoleWrite("@@ (002) :(" & @MIN & ':' & @SEC & ") Switch $sSearchPattern" & " = " & " Log-Files" & @CR) $sSearchPattern = '*.log' Case "Windows-Media-Files" ConsoleWrite("@@ (003) :(" & @MIN & ':' & @SEC & ") Switch $sSearchPattern" & " = " & " Windows-Media-Files" & @CR) $sSearchPattern = '*.wma' Case "JPEG" ConsoleWrite("@@ (004) :(" & @MIN & ':' & @SEC & ") Switch $sSearchPattern" & " = " & " JPEG" & @CR) $sSearchPattern = '*.jpeg' Case "MP3" ConsoleWrite("@@ (005) :(" & @MIN & ':' & @SEC & ") Switch $sSearchPattern" & " = " & " MP3" & @CR) $sSearchPattern = '*.mp3' EndSwitch Global $aFiles = _FileListToArrayEx($sSearchPath, $sSearchPattern) Global $sExists = '|', $sFilename = '', $sDouble = '', $iPos = 0 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) ToolTip("") EndFunc ;==>_SearchDoubles Func _FileListToArrayEx($s_path, $s_mask, $i_flag = 0, $s_exclude = -1, $f_recurse = True, $f_full_path = True) If FileExists($s_path) = 0 Then Return SetError(1, 1, 0) ; Strip trailing backslash, and add one after to make sure there's only one $s_path = StringRegExpReplace($s_path, "[\\/]+\z", "") & "\" ; 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 = "" ; Look for bad chars If StringRegExp($s_mask, "[\\/:><\|]") Or StringRegExp($s_exclude, "[\\/:><\|]") Then Return SetError(2, 2, 0) EndIf ; 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*", ";") ; 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) ; 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 & '*.*"' 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 = "" Local $i_buffer, $t_input, $t_output, $s_hold_binary $i_pid = Run(@ComSpec & " /u /c dir /b " & _ $s_recurse & "/a" & $s_dir_file_only & " " & _ $s_hold_split, "", @SW_HIDE, 4 + 2) ; 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 & "]") 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) $s_hold_out &= StringRegExpReplace(DllStructGetData($t_output, 1), "(?i)(?:\A|\v)(?:(0+\v+)|(0+))|(\v*0+\z)", "") $t_input = 0 $t_output = 0 WEnd ; 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) ; Parse data and find matches based on flags Local $a_fsplit = StringSplit(StringStripCR($s_hold_out), @LF), $s_hold_ret $s_hold_out = "" If $s_exclude Then $s_exclude = StringReplace(StringReplace($s_exclude, "*", ".*?"), ";", "|") Local $i_path_len = BinaryLen($s_path) 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 $s_hold_ret = StringTrimRight($s_hold_ret, 1) If $s_hold_ret = "" Then Return SetError(6, 6, 0) Return StringSplit($s_hold_ret, Chr(1)) EndFunc ;==>_FileListToArrayEx ;========================================================================================================================================== ; Function: _FileReadToArray2D($FILEPATH, $ARRAY [, $DELIM=-1]) ; ; Description: Read 1D/2D array from file, if $DELIM is given (<> -1) 2D array will created ; ; Parameter(s): $FILEPATH - path/filename of the file to read in an array ; $ARRAY - array variable to hold readed data ; optional $DELIM - delimiter for 2D-array entries, default -1 (none 2D-array) ; ; Requirement(s): None ; ; Return Value(s): On Success - Returns -1 ; On Failure - Returns 0 and sets @error = 1 (given file are not seperated with given delimiter or count of delimiters ; are not equal); @error = 2 (unable to open filepath) ; ; Note: If given file is delimited to create 2D-array ALL lines need the same count of delimiters, otherwise an error occurs! ; ; Author(s): BugFix ( bugfix@autoit.de ) ;========================================================================================================================================== Func _FileReadToArray2D($FILEPATH, ByRef $ARRAY, $DELIM = -1) ConsoleWrite('@@ (318) :(' & @MIN & ':' & @SEC & ') _FileReadToArray2D()' & @CR) ;### Function Trace Local $fh = FileOpen($FILEPATH, 0), $line, $var, $n = 1 If $fh = -1 Then SetError(2) Return 0 EndIf If $DELIM <> -1 Then $line = FileReadLine($fh, 1) $var = StringSplit($line, $DELIM) If IsArray($var) Then $Ubound2nd = $var[0] Local $AR[1][$Ubound2nd] $AR[0][0] = 0 Else SetError(1) Return 0 EndIf While 1 $line = FileReadLine($fh, $n) If @error = -1 Then ExitLoop $var = StringSplit($line, $DELIM) If IsArray($var) Then ReDim $AR[UBound($AR) + 1][$Ubound2nd] For $i = 0 To $Ubound2nd - 1 $AR[UBound($AR) - 1][$i] = $var[$i + 1] Next $AR[0][0] += 1 Else SetError(1) Return 0 EndIf $n += 1 WEnd Else Local $AR[1] $AR[0] = 0 While 1 $line = FileReadLine($fh, $n) If @error = -1 Then ExitLoop ReDim $AR[UBound($AR) + 1] $AR[UBound($AR) - 1] = $line $AR[0] += 1 $n += 1 WEnd EndIf FileClose($fh) $ARRAY = $AR Return -1 EndFunc ;==>_FileReadToArray2D