nacerbaaziz Posted February 5, 2018 Share Posted February 5, 2018 hello dears First I would like to apologize to you for my many questions. I have a new question if you allow I am programming an audio player for blinds I had a problem I put an option in the folders context menu to Opens the audio files that in the selected folder I did not know how to make the Autoit Search the subfolders Please provide an example of how to search for files in the subfolders Let's say, for example, MP3 files Just give me a simple example and I will try to modify it as appropriate for the program I designing it Please help me to find the solution Thanks in advance Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted February 5, 2018 Moderators Share Posted February 5, 2018 @nacerbaaziz It would help a lot if you would post your code in the future, rather than asking us to guess. If you want to search subfolders, look at _FileListToArrayRec() in the help file. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
nacerbaaziz Posted February 6, 2018 Author Share Posted February 6, 2018 Hello again Dear I tried to explain what I want in detail Because I have no idea how to do it I tried a lot but i did not succeed I only knew how to search in one folder But I did not know how to search subfolders that branch out from an original folder for that I asked for your help If you want the code you typed to search in one folder Here is the code local $dir = $fileOpen & "\" $pos = 0 GUICtrlSetData($list, "") dirAdd($dir) _GUICtrlListBox_SetCurSel($list, 0) func dirAdd($dir = $dir) _GUICtrlListBox_BeginUpdate($List) _GUICtrlListBox_Dir($List, $dir & "\*.mp3") _GUICtrlListBox_Dir($List, $dir & "\*.wav") _GUICtrlListBox_Dir($List, $dir & "\*.ogg") _GUICtrlListBox_Dir($List, $dir & "\*.mp1") _GUICtrlListBox_Dir($List, $dir & "\*.mp2") _GUICtrlListBox_Dir($List, $dir & "\*.men") _GUICtrlListBox_endUpdate($List) for $i = 0 to _GUICtrlListBox_GetCount($list)-1 $text = _GUICtrlListBox_GetText($list, $i) _GUICtrlListBox_ReplaceString($list, $i, $text & ": " & $dir & $text) next _GUICtrlListBox_SelectString($list, _GetFileName($file) & ": " & $file) endFunc I hope you can help me Link to comment Share on other sites More sharing options...
ViciousXUSMC Posted February 6, 2018 Share Posted February 6, 2018 My personal favorite way to search recursively: https://www.autoitscript.com/autoit3/docs/libfunctions/_FileListToArrayRec.htm Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted February 6, 2018 Moderators Share Posted February 6, 2018 2 hours ago, nacerbaaziz said: I hope you can help me Did you look at _FileListToArrayRec in the help file as now two people have suggested? "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
nacerbaaziz Posted February 6, 2018 Author Share Posted February 6, 2018 I tried it I have a problem I did not know how to use it if there were multiple subfolders For example a main folder and then a first subfolder with other subfolders inside it Is there a simple suggestion or example to do this Link to comment Share on other sites More sharing options...
Earthshine Posted February 6, 2018 Share Posted February 6, 2018 (edited) so you tried the code, straight from the help file, and it did not find all the files in subfolders? really? it works for me. expandcollapse popup#include <Array.au3> #include <File.au3> #include <MsgBoxConstants.au3> Example() Func Example() Local $sAutoItDir = StringLeft(@AutoItExe, StringInStr(@AutoItExe, "\", Default, -1)) If StringRight($sAutoItDir, 5) = "beta\" Then $sAutoItDir = StringTrimRight($sAutoItDir, 5) EndIf ConsoleWrite($sAutoItDir & @CRLF) ; A sorted list of all files and folders in the AutoIt installation Local $aArray = _FileListToArrayRec($sAutoItDir, "*", $FLTAR_FILESFOLDERS, $FLTAR_RECUR, $FLTAR_SORT) _ArrayDisplay($aArray, "Sorted tree") ; And now ignoring the "Include" folder $aArray = _FileListToArrayRec($sAutoItDir, "*||include", $FLTAR_FILESFOLDERS, $FLTAR_RECUR, $FLTAR_SORT) _ArrayDisplay($aArray, "No 'Include' folder") ; A sorted list of all but the .exe files in the \AutoIt3 folder $aArray = _FileListToArrayRec($sAutoItDir, "*|*.exe", $FLTAR_FILES, $FLTAR_NORECUR, $FLTAR_SORT) _ArrayDisplay($aArray, "Non .EXE files") ; And here are the .exe files we left out last time $aArray = _FileListToArrayRec($sAutoItDir, "*.exe", $FLTAR_FILES) _ArrayDisplay($aArray, ".EXE Files") ; A test for all folders and .exe files only throughout the folder tree, omitting folders beginning with I (Icons and Include) $aArray = _FileListToArrayRec($sAutoItDir, "*.exe||i*", $FLTAR_FILESFOLDERS, $FLTAR_RECUR, $FLTAR_SORT) _ArrayDisplay($aArray, "Recur with filter") ; Look for icon files - but exlude the "Icons" folder $aArray = _FileListToArrayRec($sAutoItDir, "*.ico||ic*", $FLTAR_FILES, $FLTAR_RECUR, $FLTAR_SORT) If @error Then MsgBox($MB_SYSTEMMODAL, "Ooops!", "No ico files found") Else _ArrayDisplay($aArray, "Icon files not in 'Icons' folder") EndIf ; And to show that the filter applies to files AND folders when not recursive $aArray = _FileListToArrayRec($sAutoItDir, "*.exe", $FLTAR_FILESFOLDERS, $FLTAR_NORECUR, $FLTAR_SORT) _ArrayDisplay($aArray, "Non-recur with filter") ; The filter also applies to folders when recursively searching for folders $aArray = _FileListToArrayRec($sAutoItDir, "Icons", $FLTAR_FOLDERS, $FLTAR_RECUR, $FLTAR_SORT) _ArrayDisplay($aArray, "Folder recur with filter") ; Note the exlude_folder parameter is ignored when looking for folders - "Icons" will be excluded but "Include" will still be there $aArray = _FileListToArrayRec($sAutoItDir, "*|ic*|i*", $FLTAR_FOLDERS, $FLTAR_RECUR, $FLTAR_SORT) _ArrayDisplay($aArray, "'Icons' out - 'Include' in") ; The root of C:\Windows showing hidden/system folders $aArray = _FileListToArrayRec("C:\Windows\", "*", $FLTAR_FOLDERS) _ArrayDisplay($aArray, "Show hidden folders") ; The root of C:\Windows omitting hidden/system folders $aArray = _FileListToArrayRec("C:\Windows\", "*", $FLTAR_FOLDERS + $FLTAR_NOHIDDEN + $FLTAR_NOSYSTEM) _ArrayDisplay($aArray, "Hide hidden folders") EndFunc ;==>Example Edited February 6, 2018 by Earthshine My resources are limited. You must ask the right questions Link to comment Share on other sites More sharing options...
nacerbaaziz Posted February 6, 2018 Author Share Posted February 6, 2018 please Can be more simplistic Because I did not understand well I apologize for my foolishness Link to comment Share on other sites More sharing options...
Earthshine Posted February 6, 2018 Share Posted February 6, 2018 (edited) i posted code you can copy and run. That code is out of the help file and demonstrates all the different ways you can use this function to include or exclude things and to search recursively. study the code. I can't make you understand it. #include <Array.au3> #include <File.au3> #include <MsgBoxConstants.au3> Example() Func Example() Local $sAutoItDir = StringLeft(@AutoItExe, StringInStr(@AutoItExe, "\", Default, -1)) If StringRight($sAutoItDir, 5) = "beta\" Then $sAutoItDir = StringTrimRight($sAutoItDir, 5) EndIf ConsoleWrite($sAutoItDir & @CRLF) ; A sorted list of all files and folders in the AutoIt installation Local $aArray = _FileListToArrayRec($sAutoItDir, "*", $FLTAR_FILESFOLDERS, $FLTAR_RECUR, $FLTAR_SORT) _ArrayDisplay($aArray, "Sorted tree") EndFunc the _ArrayDislplay call displays all the files under all the folders. after you have the array, (you do not need to display it) you can programatically get to each file from that list if you wish. whatever you need to do. Edited February 6, 2018 by Earthshine My resources are limited. You must ask the right questions Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted February 6, 2018 Moderators Share Posted February 6, 2018 @nacerbaaziz people are only going to hold your hand to much around here. You should know by now that expecting people to do everything for you because you "just don't understand" is not going to work. Read the content in the help file and try it for yourself. I guarantee you have not done this yet, as the code in the help file example works just fine. Come back after you have put in some effort on your own. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
nacerbaaziz Posted February 7, 2018 Author Share Posted February 7, 2018 Hello again I tried a lot I found the search method in the first subfolders But I did not know how to search folders that branch out from subfolders Is there a way to do this This is the code that I've tried #include <Array.au3> ; Only required to display the arrays #include <MsgBoxConstants.au3> #include <file.au3> local $files, $next local $folder = FileSelectFolder("please select a folder", "") $files = FileFindFirstFile($folder & "\*.mp3") while 1 $next = FileFindnextFile($files) if @error then exitLoop fileWrite(@scriptDir & "\files.txt", $folder & "\" & $next & @crlf) WEnd Local $aArray = _fileListToArrayRec($folder, "*", $FLTAR_FOLDERS, $FLTAR_RECUR, $FLTAR_SORT) for $i = 1 to $aArray [0] $files = FileFindFirstFile($folder & "\" & $aArray [$i] & "\*.mp3") while 1 $next = FileFindnextFile($files) if @error then exitLoop fileWrite(@scriptDir & "\files.txt", $folder & "\" & $aArray[$i] & "\" & $next & @crlf) WEnd next exit Please help me Thanks in advance Link to comment Share on other sites More sharing options...
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