careca Posted November 3, 2012 Share Posted November 3, 2012 Hi, been searching around, and many asked a similar question, tried some solutions on my problem, but couldn't do it. Problem is, got a path, and want the script to search for a file (prefs.js) in a folder, but one of the folders change it's name every now and then, well, i do, and don't want to change the script every time, so i thought someone could help me out. Path is: Drive\PROGS\01 INSTALL\**VariableFolderName**\Profiles\Profiles\default.default\prefs.js FileFindFirstFile doesn't support wilcards on the path, only the file, meaning im stuck. $aArray = DriveGetDrive('FIXED') If @error Then MsgBox(4096, "DriveGetDrive", "It appears an error occurred.") Else For $i = 1 To $aArray[0] FileFindFirstFile($aArray[$i] & '\PROGS\01 INSTALL\'& * &'\Profiles\Profiles\default.default\prefs.js') If FileExists($aArray[$i] & '\PROGS\01 INSTALL\'& * &'\Profiles\Profiles\default.default\prefs.js') Then Else MsgBox(0, "Error", "No files/directories matched the search pattern") EndIf Next EndIf Spoiler Renamer - Rename files and folders, remove portions of text from the filename etc. GPO Tool - Export/Import Group policy settings. MirrorDir - Synchronize/Backup/Mirror Folders BeatsPlayer - Music player. Params Tool - Right click an exe to see it's parameters or execute them. String Trigger - Triggers pasting text or applications or internet links on specific strings. Inconspicuous - Hide files in plain sight, not fully encrypted. Regedit Control - Registry browsing history, quickly jump into any saved key. Time4Shutdown - Write the time for shutdown in minutes. Power Profiles Tool - Set a profile as active, delete, duplicate, export and import. Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes. NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s. IUIAutomation - Topic with framework and examples Au3Record.exe Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 3, 2012 Moderators Share Posted November 3, 2012 careca,My RecFileListToArray UDF can help you here. Just search all the possible subfolders for the file like this: #include <Array.au3> #include <RecFileListToArray.au3> $aList = _RecFileListToArray("DrivePROGS01 INSTALL", "prefs.js", 1, 1, 0, 2) If IsArray($aList) Then ; The array will contain all the "prefs.js" files found _ArrayDisplay($aList, "Found") Else MsgBox(0, "Ooops", "File not found") EndIfI hope it helps. 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 Link to comment Share on other sites More sharing options...
careca Posted November 3, 2012 Author Share Posted November 3, 2012 Hello, thanks for the answer, this seems to send me in the right track, but i need to retrieve the path and it doesn't seem to work. like so: #include #include $aArray = DriveGetDrive('FIXED') For $i = 1 To $aArray[0] $aList = _RecFileListToArray($aArray[$i]&"PROGS01 INSTALL", "prefs.js", 1, 1, 0, 2) If IsArray($aList) Then ; The array will contain all the "prefs.js" files found MsgBox(0, 'Info', "Found in: "& $aArray[$i]) ;_ArrayDisplay($aList, "Found") MsgBox(0, 'Info', $aList) Else MsgBox(0, "Error", "Not found in: " &$aArray[$i]) EndIf Next From $aList I get an empty msgbox, yes, it is supposed to send the data to an array, but then again, tried with an array and it still didn't show the data in that array, here it only shows the drive letter, where it found the file, so it seems to work in part, what have i messed up? expandcollapse popup#region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon=ResourcesFox.ico #AutoIt3Wrapper_Res_Icon_Add=ResourcesFox.ico #AutoIt3Wrapper_Run_Tidy=y #endregion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <Array.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <ButtonConstants.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <ListViewConstants.au3> #include <RecFileListToArray.au3> Opt("GUIOnEventMode", 1) Opt("TrayAutoPause", 0) Opt("TrayIconDebug", 1) Local $sPath $Profile = StringReplace(@DesktopDir, 'Desktop', '') $Form1 = GUICreate("Firefox Profile Backup", 380, 255, 190, 125) GUISetOnEvent($GUI_EVENT_CLOSE, "Close") $Backup = GUICtrlCreateButton("Backup", 10, 220, 75, 25) GUICtrlSetOnEvent($Backup, "Backup") $Restore = GUICtrlCreateButton("Restore", 120, 220, 75, 25) GUICtrlSetOnEvent($Restore, "Restore") $Exit = GUICtrlCreateButton("Exit", 230, 220, 75, 25) GUICtrlSetOnEvent($Exit, "Close") $cListView = GUICtrlCreateListView("Hdd|Path", 10, 80, 360, 130) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 50) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 300) $Label1 = GUICtrlCreateLabel("Profile Folder", 10, 10, 130, 17) $Label2 = GUICtrlCreateLabel("Backup/Restore Folder(s)", 10, 60, 130, 17) $Input1 = GUICtrlCreateInput($Profile & 'AppDataRoamingMozillaFirefox', 10, 30, 360, 21) $aArray = DriveGetDrive('FIXED') If @error Then MsgBox(4096, "DriveGetDrive", "It appears an error occurred.") Else For $i = 1 To $aArray[0] $aList = _RecFileListToArray($aArray[$i] & "PROGS01 INSTALL", "prefs.js", 1, 1, 0, 2) If IsArray($aList) Then GUICtrlCreateListViewItem(StringUpper($aArray[$i]) & '|' & $aList, $cListView) EndIf Next EndIf GUISetState(@SW_SHOW) Spoiler Renamer - Rename files and folders, remove portions of text from the filename etc. GPO Tool - Export/Import Group policy settings. MirrorDir - Synchronize/Backup/Mirror Folders BeatsPlayer - Music player. Params Tool - Right click an exe to see it's parameters or execute them. String Trigger - Triggers pasting text or applications or internet links on specific strings. Inconspicuous - Hide files in plain sight, not fully encrypted. Regedit Control - Registry browsing history, quickly jump into any saved key. Time4Shutdown - Write the time for shutdown in minutes. Power Profiles Tool - Set a profile as active, delete, duplicate, export and import. Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes. NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s. IUIAutomation - Topic with framework and examples Au3Record.exe Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 3, 2012 Moderators Share Posted November 3, 2012 careca, what have i messed up?This: ;_ArrayDisplay($aList, "Found") MsgBox(0, 'Info', $aList) You cannot display an array in a MsgBox - that is why I used _ArrayDisplay. Try using this: MsgBox(0, 'Info', $aList[1]) Now you display the first file found - which should be the one you are looking for. 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 Link to comment Share on other sites More sharing options...
careca Posted November 3, 2012 Author Share Posted November 3, 2012 Now you display the first file found - which should be the one you are looking for. M23, ok, thanks, that covers the msgbox, any hope for the second case? To display in my ListViewItem? Spoiler Renamer - Rename files and folders, remove portions of text from the filename etc. GPO Tool - Export/Import Group policy settings. MirrorDir - Synchronize/Backup/Mirror Folders BeatsPlayer - Music player. Params Tool - Right click an exe to see it's parameters or execute them. String Trigger - Triggers pasting text or applications or internet links on specific strings. Inconspicuous - Hide files in plain sight, not fully encrypted. Regedit Control - Registry browsing history, quickly jump into any saved key. Time4Shutdown - Write the time for shutdown in minutes. Power Profiles Tool - Set a profile as active, delete, duplicate, export and import. Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes. NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s. IUIAutomation - Topic with framework and examples Au3Record.exe Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 3, 2012 Moderators Share Posted November 3, 2012 careca, Now you know how to get the string I would have thought you could have worked that out for yourself. Try this; GUICtrlCreateListViewItem(StringUpper($aArray[$i]) & "|" & StringTrimLeft($aList[1], 3), $cListView) We need to trim the path to get rid of the leading drive letter and the ":". 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 Link to comment Share on other sites More sharing options...
careca Posted November 3, 2012 Author Share Posted November 3, 2012 (edited) Im sorry, failed to explain correctly the problem, what i need is to display all paths for the file that were found, in ListViewItem, not just the first found, because i have more than one hdd, so i got to check if there are those files in other hdd's, tried to use your function as an array, and that doesn't seem to work. Can your function be used as an array? as im using DriveGetDrive? Hope i expressed myself right. Sorry for the mess up. Example of what im trying $aArray = DriveGetDrive('FIXED') If @error Then MsgBox(4096, "DriveGetDrive", "It appears an error occurred.") Else For $i = 1 To $aArray[0] For $u = 1 To $aList[0] $aList = _RecFileListToArray($aArray[$i] & "PROGS01 INSTALL", "prefs.js", 1, 1, 0, 2) GUICtrlCreateListViewItem(StringUpper($aArray[$i])& '|' & StringTrimLeft($aList[$u], 3), $cListView) Next Next EndIf EDIT: i messed up bad, just noticed, fixing... EDIT2: nope, still messed up Edited November 3, 2012 by careca Spoiler Renamer - Rename files and folders, remove portions of text from the filename etc. GPO Tool - Export/Import Group policy settings. MirrorDir - Synchronize/Backup/Mirror Folders BeatsPlayer - Music player. Params Tool - Right click an exe to see it's parameters or execute them. String Trigger - Triggers pasting text or applications or internet links on specific strings. Inconspicuous - Hide files in plain sight, not fully encrypted. Regedit Control - Registry browsing history, quickly jump into any saved key. Time4Shutdown - Write the time for shutdown in minutes. Power Profiles Tool - Set a profile as active, delete, duplicate, export and import. Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes. NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s. IUIAutomation - Topic with framework and examples Au3Record.exe Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 3, 2012 Moderators Share Posted November 3, 2012 careca, Im sorry, failed to explain correctly the problemA good explanation always helps. This should run through all the drives and look for all instances of the file: $aArray = DriveGetDrive('FIXED') If @error Then MsgBox(4096, "DriveGetDrive", "It appears an error occurred.") Else For $i = 1 To $aArray[0] $aList = _RecFileListToArray($aArray[$i] & "PROGS01 INSTALL", "prefs.js", 1, 1, 0, 2) If IsArray($aList) Then For $j = 1 To $aList[0] GUICtrlCreateListViewItem(StringUpper($aArray[$i]) & "|" & StringTrimLeft($aList[$j], 3), $cListView) Next EndIf Next EndIf It works for me when I test it - how about you? 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 Link to comment Share on other sites More sharing options...
careca Posted November 3, 2012 Author Share Posted November 3, 2012 It works for me when I test it - how about you? Works perfect! Thank you Sir.I was about to get there, but there was this error, and after a long time i noticed there was a ) missing, and that gave me lots of errors, endif missing, next missing etc. LOLGreetings,careca. Spoiler Renamer - Rename files and folders, remove portions of text from the filename etc. GPO Tool - Export/Import Group policy settings. MirrorDir - Synchronize/Backup/Mirror Folders BeatsPlayer - Music player. Params Tool - Right click an exe to see it's parameters or execute them. String Trigger - Triggers pasting text or applications or internet links on specific strings. Inconspicuous - Hide files in plain sight, not fully encrypted. Regedit Control - Registry browsing history, quickly jump into any saved key. Time4Shutdown - Write the time for shutdown in minutes. Power Profiles Tool - Set a profile as active, delete, duplicate, export and import. Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes. NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s. IUIAutomation - Topic with framework and examples Au3Record.exe 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