cramaboule Posted 13 hours ago Posted 13 hours ago (edited) Hello, I am searching files (e.g.) *.jpg inside (e.g.) 'cramy' folders like C:\AutoIt\[some folders]\cramy\*.jpg AND as well .jpg inside folders ending with 25: C:\AutoIt\[some folders]\[some folders]\[some folders]\*25\*.jpg I have some code: Local $aJPG[1]=[0], $aOtherJPG[1]=[0] For $i = 1 To $aDrive[0] $aJPG = _FileListToArrayRec($aDrive[$i] & "\", "cramy", $FLTA_FOLDERS, $FLTAR_RECUR, $FLTAR_NOSORT, $FLTAR_FULLPATH) For $j = 1 To aJPG[0] $aFic1 = _FileListToArray($aJPG[$j], "*.jpg", $FLTA_FILES, True) $num = _ArrayConcatenate(aJPG, aJPG1, 1) $aJPG[0] = $num - 1 Next $aOtherJPG = _FileListToArrayRec($aDrive[$i] & "\", "*25", $FLTA_FOLDERS, $FLTAR_RECUR, $FLTAR_NOSORT, $FLTAR_FULLPATH) For $j = 1 To $aOtherJPG[0] $aOtherJPG1 = _FileListToArray($aOtherJPG[$j], "*.jpg", $FLTA_FILES, True) $num = _ArrayConcatenate($aOtherJPG, $aOtherJPG1, 1) aOtherJPG[0] = $num - 1 Next Next Is it possible to shorten the code ? I tried: $aJPG = _FileListToArrayRec($aDrive[$i] & '\', 'cramy||;*25||', $FLTA_FOLDERS, $FLTAR_RECUR, $FLTAR_NOSORT, $FLTAR_FULLPATH) But it doesn't work ! Thanks for your help! C. Edited 11 hours ago by cramaboule My Autoit programs: MAC Address - - Delete Temp Files - - Ping Test - - Play Video with VLC full screen dual monitors - - Set IP - - Pics Converter - - AutoUpdater - - CPU Usage - - Ending Script Nicely - - GDI+ GUI crossfades (slide transitions) - - Beamer - - Search and Search in Files - - Silent Ninite Others: Export Icons into Dll - - My website
Solution ioa747 Posted 11 hours ago Solution Posted 11 hours ago I did it like this. #include <Array.au3> #include <File.au3> Local $aDrive[] = [2, "C:\", "D:\"] Local $aDir, $aJpg Local $aResult = 0 Local $bFirstArray = True For $i = 1 To $aDrive[0] $aDir = _FileListToArrayRec($aDrive[$i], "cramy;*25", $FLTA_FOLDERS, $FLTAR_RECUR, $FLTAR_NOSORT, $FLTAR_FULLPATH) If @error Then ConsoleWrite("No folders found matching the criteria." & @CRLF) Else For $j = 1 To $aDir[0] $aJpg = _FileListToArray($aDir[$j], "*.jpg", $FLTA_FILES, True) If @error Then ConsoleWrite("No files found matching the criteria, in folder: " & $aDir[$j] & @CRLF) Else If $bFirstArray Then $aResult = $aJpg $bFirstArray = False Else _ArrayConcatenate($aResult, $aJpg, 1) $aResult[0] = UBound($aResult) - 1 EndIf EndIf Next EndIf Next ; If $aResult is an array, display it. If IsArray($aResult) Then _ArrayDisplay($aResult, "All .jpg Files Found (" & $aResult[0] & " Total)") Else ConsoleWrite("SUMMARY: No .jpg files were successfully collected." & @CRLF) EndIf cramaboule 1 I know that I know nothing
cramaboule Posted 11 hours ago Author Posted 11 hours ago 18 minutes ago, ioa747 said: I did it like this. #include <Array.au3> #include <File.au3> Local $aDrive[] = [2, "C:\", "D:\"] Local $aDir, $aJpg Local $aResult = 0 Local $bFirstArray = True For $i = 1 To $aDrive[0] $aDir = _FileListToArrayRec($aDrive[$i], "cramy;*25", $FLTA_FOLDERS, $FLTAR_RECUR, $FLTAR_NOSORT, $FLTAR_FULLPATH) If @error Then ConsoleWrite("No folders found matching the criteria." & @CRLF) Else For $j = 1 To $aDir[0] $aJpg = _FileListToArray($aDir[$j], "*.jpg", $FLTA_FILES, True) If @error Then ConsoleWrite("No files found matching the criteria, in folder: " & $aDir[$j] & @CRLF) Else If $bFirstArray Then $aResult = $aJpg $bFirstArray = False Else _ArrayConcatenate($aResult, $aJpg, 1) $aResult[0] = UBound($aResult) - 1 EndIf EndIf Next EndIf Next ; If $aResult is an array, display it. If IsArray($aResult) Then _ArrayDisplay($aResult, "All .jpg Files Found (" & $aResult[0] & " Total)") Else ConsoleWrite("SUMMARY: No .jpg files were successfully collected." & @CRLF) EndIf $aDir = _FileListToArrayRec($aDrive[$i], "cramy;*25", $FLTA_FOLDERS, $FLTAR_RECUR, $FLTAR_NOSORT, $FLTAR_FULLPATH) Arrr,.... that's the syntax I was looking for ! Thanks ioa747 1 My Autoit programs: MAC Address - - Delete Temp Files - - Ping Test - - Play Video with VLC full screen dual monitors - - Set IP - - Pics Converter - - AutoUpdater - - CPU Usage - - Ending Script Nicely - - GDI+ GUI crossfades (slide transitions) - - Beamer - - Search and Search in Files - - Silent Ninite Others: Export Icons into Dll - - My website
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now