BlazerV60 Posted June 14, 2014 Posted June 14, 2014 (edited) Hello everyone, I'm trying to make a script that tells me the location of a specified file, in this case lets say I'm searching for a file named "hamster.jpg" So I want to search my entire computer for this file, so I'm using Melba's UDF (RecFileListToArray). My problem is that I seem to only be able to find hamster.jpg if I do a search for ".jpg" (as seen in my code below). This also shows me all the other .jpg's I have on my computer, which is fine. If I do a search for "hamster", I won't see any results. So it seems like I can only search file extensions and not the file name itself. Can anyone guide me on how to make my code search for file names as well? Thank you, Brian #include <Array.au3> #include <RecFileListToArray.au3> Example() Func Example() Local $aArray, $aDrives = DriveGetDrive("FIXED") ;Makes sure all the drives are searched If @error = 0 Then For $i = 1 To $aDrives[0] $aArray = _RecFileListToArray($aDrives[$i] & "", "*.jpg", 1, 1, 0, 2) If @error Then ContinueLoop EndIf For $j = 1 To $aArray[0] ConsoleWrite($aArray[$j] & @CRLF) Next Next EndIf EndFunc ;==>Example So in the above code, if I change the "*.jpg" to "*hamster", I won't be able to find my hamster picture D:. EDIT: I figured it out. Wow.. The only different thing I had to do in order to find the file name was write "hamster" on the left side of the * instead of the right side of the * Edited June 14, 2014 by BlazerV60
Solution jguinch Posted June 14, 2014 Solution Posted June 14, 2014 you can also use _FileListToArrayRec : $aArray =_FileListToArrayRec ( $aDrives[$i] , "hamster.jpg" , 1 , 1 ) Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF
BlazerV60 Posted June 14, 2014 Author Posted June 14, 2014 you can also use _FileListToArrayRec : $aArray =_FileListToArrayRec ( $aDrives[$i] , "hamster.jpg" , 1 , 1 ) Thanks for your feedback, The _FileListToArrayRec seems to be doing the same thing for me. If I change the "hamster.jpg" parameter to "hamster" i can't find the picture, but if i change it to ".jpg" or "hamster.jpg" then I can find it. Is there a way to find it without having to enter in the extension?
Moderators Melba23 Posted June 14, 2014 Moderators Posted June 14, 2014 BlazerV60, Is there a way to find it without having to enter in the extension?If a file has an extension you need to tell the function that it exists - by searching for simply "hamster" you will only get files of that name with no extension returned. Try this:$aArray =_FileListToArrayRec($aDrives[$i], "hamster.*", 1, 1)Now the function will return all files which are named hamster and have (or indeed do not have) an extension - which should include the one for which you are looking, but might well include others too. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
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