Popular Post AZJIO Posted September 22, 2011 Popular Post Share Posted September 22, 2011 (edited) Function to search for files or folders. FileOperations.7z - version 1.8.4 from 2014.03.18, (pastebin: Ru , Ru-example) _FO_CorrectMask (Help) _FO_FileSearch (Help) _FO_FolderSearch (Help) _FO_SearchEmptyFolders (Help) _FO_FileDirReName (Help) _FO_GetCopyName (Help) _FO_FileBackup (Help) _FO_PathSplit (Help) _FO_IsDir (Help) _FO_ShortFileSize (Help) _FO_IsEmptyFolder (Help) _FO_CreateFile alternative: RecFileListToArray (Melba23) FileListToArrayEx (DXRW4E) FileListToArray (SmOke_N) FileFindFirstFile (NIKZZZZ) old _FileFindFirstFile, _FileFindNextFile (AZJIO) FileDirList (MrCreatoR, amel27), (cmd.exe Dir /b) FileListToArrayRecursive + _Callback (therks) FileSearch (AZJIO), link2 myFileListToArray_AllFiles (akurakkauaaa) Update Spoiler 24.05.2014 Added function _FO_CreateFile 18.03.2014 Updated _FO_IsEmptyFolder 02.08.2013 _FO_IsEmptyFolder 15.06.2013 _FO_FileSearch + $vExcludeFolders, $iExcludeDepth. Modified $sLocale. _FO_ShortFileSize 28.04.2013 _FO_SearchEmptyFolders: I used _FO_IsDir instead of FileExists 27.04.2013 $sPath = "" now it causes a mistake 20.11.2012 Added function _FO_IsDir 08.08.2012 case sensitive 09.06.2012 Added function __FO_UserLocale 20.05.2012 Added function _FO_FileBackup, _FO_PathSplit, Update _FO_SearchEmptyFolders 14.05.2012 Added function _FO_FileDirReName, _FO_GetCopyName 16.02.2012 Added function _FO_SearchEmptyFolders, Added the prefix "_FO" 10.01.2012 Added function _CorrectMask 27.11.2011 Fixed: correction masks; existence of a path 09.11.2011 Fixed: Separator character ";" replaced by "|" 24.10.2011 Fixed: (Full=3)+(Arr=1), _FolderSearch faster 22.10.2011 Fixed: Return __GetListMask 17.10.2011 Added: forced $TypeMask 15.10.2011 Fixed: @error = 3 - not found 14.10.2011 Fixed: Mask=(*z.exe;a*.msi) or (exe;msi). _FolderSearch+($Include = True/False) 12.10.2011 Fixed: __FileSearchMask 10.10.2011 Fixed: If $Include=False, Mask(__FileSearchMask) Accordingly, the updated (26.11.2012) program: >TextReplace, >Create_list_files, >Search_duplicates, >Synchronization Accordingly, the updated (22.11.2011) program: >ReName Edited March 5, 2023 by AZJIO MikahS, mesale0077, JScript and 4 others 7 My other projects or all Link to comment Share on other sites More sharing options...
wakillon Posted September 24, 2011 Share Posted September 24, 2011 Excellent ! 5.64 sec for 313572 files ! It takes more time to display array than searching files... Thanks to share ! AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts Link to comment Share on other sites More sharing options...
Fr33b0w Posted October 21, 2011 Share Posted October 21, 2011 (edited) Hi guys! This is amazing function and it work fine with files. Problem is that I couldn't make it to work with folders... #include <File.au3> #include <Array.au3> ; i dont need this but i also did try with arrays #include <_FileSearch.au3> #include <string.au3> ; $file contain list of folders separated by @CR which I would like to find and copy to desired place ; filenames inside contain symbols like "-" "_" "(" ")" but that shouldnt be a problem $file="search.txt" ; set counter on 1st line in search.txt $cnt01=1 ; $destination where i want all files to be copied to $destination="f:\S\@@\" ; $countlines $countlines=_FileCountLines("search.txt") Do ; $fol is the name of first folder from the list (search.txt) that i want to find and copy to $destination $fol=FileReadLine($file,$cnt01) ; $relpath should contain full path to first folder that has been found ; 15 is search depth, 1 means i want full path to a folder and 0 means it wont be an array $folpath=_FolderSearch('f:\M\',$fol,15,1,0) ; copy folder and its contents to a $destination ,1 and overwrite files if there are any DirCopy($folpath, $destination, 1) ; increase counter to read next line in search.txt $cnt01 = $cnt01 + 1 ; work like that until last line in file Until $cnt01 > $countlines ; do a beep beep when everything is done Beep(1000,100) Exit I did try and put MsgBox with variables to see what happens but couldnt make it to find first folder i would like to be found It gets first folder name well but I couldnt get the hit from function: $relpath=_FolderSearch('f:\M\',$fol,15,1,0) Contents of a search.txt would be something like this: Pictures_Not-Vacation_Sea-(2001)-Me Video_And_Sounds-Vacation_Sea-(2001)-Me etc. Edited October 21, 2011 by Fr33b0w Link to comment Share on other sites More sharing options...
AZJIO Posted October 21, 2011 Author Share Posted October 21, 2011 (edited) Fr33b0w ; $Include = True (parameters can not be ignored) ; 1 - result in an ARRAY where $array[0]=number of folders (BY DEFAULT) $folpath=_FolderSearch('f:\M\',$fol, True,15) If Not @error Then For $i = 1 to $folpath[0] DirCopy($folpath[$i], $destination, 1) Next EndIf the script works well, tested#include <File.au3> #include <_FileSearch.au3> $file="search.txt" $cnt01=1 $destination="F:\S\@@\" $countlines=_FileCountLines("search.txt") While $cnt01 <= $countlines $fol=FileReadLine($file,$cnt01) ; $Include = True (parameters can not be ignored) ; 1 - result in an ARRAY where $array[0]=number of folders (BY DEFAULT) $folpath=_FolderSearch('F:\M\',$fol, True,15) If Not @error Then For $i = 1 to $folpath[0] DirCopy($folpath[$i], $destination&'\'&$fol, 1) Next EndIf $cnt01 += 1 WEnd Beep(1000,100) Edited October 21, 2011 by AZJIO My other projects or all Link to comment Share on other sites More sharing options...
AZJIO Posted October 22, 2011 Author Share Posted October 22, 2011 (edited) 1. Try _FileSearch_example 2. Try $fol = '*' 3. Check the error after the function _FolderSearch $folpath=_FolderSearch('F:\M\',$fol, True,15) MsgBox(0, 'Message', @error) 4. Check that the folder names are in the file search.txt 5. Check the simplified method $folpath=_FolderSearch('F:\M\', 'Pictures_Not-Vacation_Sea-(2001)-Me', True,15) MsgBox(0, 'Message', @error) Edited October 22, 2011 by AZJIO Fr33b0w 1 My other projects or all Link to comment Share on other sites More sharing options...
Fr33b0w Posted October 22, 2011 Share Posted October 22, 2011 I am so sorry. I was lost my head while I had problem with script before You helped me first time and since I was trying everything to make it work I forgot to switch back hdd letter. So I wasted Your time even more then it was needed (mine time also). Script works in background and it works perfect. This what You made is very useful tool, at least it is for me so I thank You very much for that (spasibo)! Again, thank You for Your time. I wouldnt make it if You didnt helped me! Link to comment Share on other sites More sharing options...
pbc0011 Posted November 23, 2011 Share Posted November 23, 2011 (edited) I have been using _filesearch for a few months but I have recently ran into a problem. Currently I can only get it to work over the network if I map a drive to the other machine. Has anyone else been able to use the IP to do searches? I.E. 192.168.0.10folder Every time I try it returns no results. Another question I have is it states in the comments "If an empty folder, it returns an empty string or array with one element $array[0]=0". Now I have very limited experience with Autoit but I have taken classes in C and C++. Can you have an array with only one element in autoit? The reason why I ask is from my testing it seems that it is not returning an array when no files are found, just a variable with value "0" in it. Thank you for this function and any help you can offer. Edited November 23, 2011 by pbc0011 Link to comment Share on other sites More sharing options...
AZJIO Posted November 23, 2011 Author Share Posted November 23, 2011 (edited) Function is updated, and now if the folder is empty or nothing is found, it returns an @error=3 192.168.0.10folderRemove the line in the function _FileSearch and _FolderSearch If Not StringRegExp($Path, '(?i)^[a-z]:[^/:*?"<>|]*$') Or StringInStr($Path, '') Then Return SetError(1, 0, '') I tried to use a regular expression to validate the path. But I do not understand what paths are used for network drives to make a regular expression. Maybe it does not even need to check. Edited November 23, 2011 by AZJIO My other projects or all Link to comment Share on other sites More sharing options...
pbc0011 Posted November 24, 2011 Share Posted November 24, 2011 Azjio, Thanks for the quick response and making the adjustments. I'm having a little trouble understanding what exactly the @error macro does but Ill have to dig a little deeper into the help file. I really do need the ability to search over the network so I'm going to try and do a little research on that too. Link to comment Share on other sites More sharing options...
AZJIO Posted November 24, 2011 Author Share Posted November 24, 2011 pbc0011 $FileList=_FileSearch($Path) Switch @error Case 1 MsgBox(0, 'Error', 'Invalid path') Case 2 MsgBox(0, 'Error', 'Invalid mask') Case 3 MsgBox(0, 'Error', 'not found') Case Else MsgBox(0, 'no errors', 'found') EndSwitch $FileList=_FileSearch($Path) If Not @error Then ; activity EndIf $FileList=_FileSearch($Path) If @error Then Exit My other projects or all Link to comment Share on other sites More sharing options...
pbc0011 Posted November 24, 2011 Share Posted November 24, 2011 Ahh thank you Link to comment Share on other sites More sharing options...
AZJIO Posted November 27, 2011 Author Share Posted November 27, 2011 When the correction masks are allowed whitespace characters and point at the beginning of the file name. Fixed three bugs are not critical. Added check for existence of the path, instead of validation. My other projects or all Link to comment Share on other sites More sharing options...
JScript Posted January 9, 2012 Share Posted January 9, 2012 Nice script @AZJIO, thanks for sharing! Five stars from me... Regards, João Carlos. http://forum.autoitbrasil.com/ (AutoIt v3 Brazil!!!) Somewhere Out ThereJames Ingram Download Dropbox - Simplify your life!Your virtual HD wherever you go, anywhere! Link to comment Share on other sites More sharing options...
AZJIO Posted January 23, 2012 Author Share Posted January 23, 2012 _PathSearch #include <Array.au3> ; для _ArrayDisplay #include <_FileSearch.au3> $FileList=_PathSearch('C:WINDOWSsystem', '*ystemm*|*ystem*z*|*ystemo*', True, 125) ; $FileList=_GetListMask('C:WINDOWSsystem', '*ystemM*', False, 125) MsgBox(0, 'Сообщение', $FileList) $FileList = StringSplit($FileList, @CRLF, 1) _ArrayDisplay($FileList, UBound($FileList)&' - RegExp') ; Получение списка и обработка регулярным выражением Func _PathSearch($Path, $Mask, $Include, $Depth) Local $aFileList, $FileList $FileList=_FileSearch($Path, '*', True, $Depth, 1, 0) $Mask = StringReplace(StringReplace(StringRegExpReplace($Mask, '[][$^.{}()+]', '$0'), '?', '.'), '*', '.*?') If $Include Then $aFileList = StringRegExp($FileList, '(?mi)^(' & $Mask & ')(?:r|z)', 3) $FileList = '' For $i = 0 To UBound($aFileList) - 1 $FileList &= $aFileList[$i] & @CRLF Next Else $FileList = StringRegExpReplace($FileList & @CRLF, '(?mi)^(' & $Mask & ')rn', '') EndIf $FileList = StringReplace(StringTrimRight($FileList, 2), '|', '') Return $FileList EndFunc My other projects or all Link to comment Share on other sites More sharing options...
Chimaera Posted January 23, 2012 Share Posted January 23, 2012 Thanks for the PathSearch option Ive just been playing with it to try and understand it with this $FileList=_PathSearch('C:Program Files (x86)', 'mbam.exe|mbamgui.exe', True, 125) MsgBox(0, '?????????', $FileList) $FileList = StringSplit($FileList, @CRLF, 1) _ArrayDisplay($FileList, UBound($FileList)&' - RegExp') But it doesn't return anything.. what have i missed? Edit even running the one you posted unaltered returns nothing either If Ive just helped you ... miracles do happen. Chimaera CopyRobo() * Hidden Admin Account Enabler * Software Location From Registry * Find Display Resolution * _ChangeServices() Link to comment Share on other sites More sharing options...
AZJIO Posted January 23, 2012 Author Share Posted January 23, 2012 (edited) 'mbam.exe|mbamgui.exe' - it's files, look for them using _FileSearch will be faster.first try to play with _FileSearch_Gui_Test.au3using _PathSearch need to change the mask of '*mbam.exe |*mbamgui.exe' Edited January 23, 2012 by AZJIO My other projects or all Link to comment Share on other sites More sharing options...
Chimaera Posted January 23, 2012 Share Posted January 23, 2012 (edited) there we go I knew it would be something stupid im doing lol PathSearch will hopefully be usefull to me because i can search for more than one file to guarentee its installed but return the path if they exist, which i can feed to another function Is wildcards in the path possible? ie: Program* Im aware i can use @ProgramFilesDir, i was just curious? благодарность Jez Edited January 23, 2012 by Chimaera If Ive just helped you ... miracles do happen. Chimaera CopyRobo() * Hidden Admin Account Enabler * Software Location From Registry * Find Display Resolution * _ChangeServices() Link to comment Share on other sites More sharing options...
AZJIO Posted January 23, 2012 Author Share Posted January 23, 2012 Chimaera_FileSearch - searches for file names_FileSearch(@WindowsDir, '*yste*')C:WINDOWSsystem32configsystem.LOG_PathSearch searches for text in a file path, and allow the "" _PathSearch(@WindowsDir, '*yste*')C:WINDOWSsystem32shell32.dll My other projects or all Link to comment Share on other sites More sharing options...
Belini Posted April 16, 2012 Share Posted April 16, 2012 Excellent AZJIO this UDF, congratulations for the beautiful work. My Codes: Virtual Key Code UDF: http://www.autoitscript.com/forum/topic/138246-virtual-key-code-udf/ GuiSplashTextOn.au3: http://www.autoitscript.com/forum/topic/143542-guisplashtexton-udf/ Menu versions of Autoit: http://www.autoitscript.com/forum/topic/137435-menu-versions-of-autoit/#entry962011 Selects first folder of letters: ]http://www.autoitscript.com/forum/topic/144780-select-folders-by-letter/#entry1021708/spoiler] List files and folders with long addresses.: http://www.autoitscript.com/forum/topic/144910-list-files-and-folders-with-long-addresses/#entry102 2926 Program JUKEBOX made in Autoit:some functions:http://www.youtube.com/watch?v=WJ2tC2fD5Qs Navigation to search:http://www.youtube.com/watch?v=lblwOFIbgtQ Link to comment Share on other sites More sharing options...
AZJIO Posted August 9, 2012 Author Share Posted August 9, 2012 (edited) for functions _FO_FileSearch, _FO_FolderSearch $sLocale - Symbols of the local language (any non-Latin), to ignore the case when searching $FileList=_FO_FileSearch($Path, '*Пример*', True, 125, 3, 1, 1, 'А-яЁё') Update ;$sLocale - case sensitive. ; |0 - not case sensitive (only for 'A-z'), by default. ; |1 - case sensitive (for any characters) ; |<symbols> - not case sensitive, specified range of characters from local languages. For example 'А-яЁё'. 'A-z' is not required, they are enabled by default. Edited April 21, 2013 by AZJIO My other projects or all 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