michaelslamet Posted March 5, 2011 Share Posted March 5, 2011 Hi M23,Can use show me example code using this UDF? I would like to search folder ABC from $source_folder. If found then copy entire folder to $dest_folder. If not found that find any files which name contain string ABC in it and copy to $dest_folderThanks for your help and your time Answering my own question: searching through this forum I found a example code for _RecFileListToArray. Let me try to code it first because asking more questions Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 5, 2011 Moderators Share Posted March 5, 2011 michaelslamet, Delighted you want to try and code something yourself - I will be here if you run into difficulties. 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...
michaelslamet Posted March 5, 2011 Share Posted March 5, 2011 michaelslamet, Delighted you want to try and code something yourself - I will be here if you run into difficulties. M23 Thanks M23 And this is my first difficulties using _RecFileListToArray I found a folder that match my criteria: $search_result = _RecFileListToArray(GUICtrlRead($location), "*" & $find_criteria & "*", 2, 1, 0, 2) I try to copy the result to $dest_folder: DirCopy($search_result[$counter], @Desktopdir & "\", 1) The problem is DirCopy only copy the content of folder $search_result to $dest_folder, not the folder itself. example: search result: folder ABC, which is contain 1.txt and 2.txt Dircopy will copy the 1.txt and 2.txt to $dest_folder so $dest_folder will content 1.txt and 2.txt I want $dest_folder contain folder ABC and inside folder ABC there is 1.txt and 2.txt This is not a _RecFileListToArray problem And I hope you can understand what i'm trying to say Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 5, 2011 Moderators Share Posted March 5, 2011 michaelslamet,You just need to correctly specify the destination path that you want. I assume that $search_result[$counter] looks like this - Path\path\path\ABC. You need to get the ABC part of the total path and then do this:DirCopy($search_result[$counter], @Desktopdir & "\ABC", 1)Now the command will create the ABC folder on the desktop and copy over the files within as you wish. You might find this useful to get the folder name from the path: $sPath = "Path\path\path\ABC" $sFolder = StringRegExpReplace($sPath, "^.*\\(.*)", "\1") ConsoleWrite($sFolder & @CRLF)All clear? 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...
michaelslamet Posted March 5, 2011 Share Posted March 5, 2011 michaelslamet, You just need to correctly specify the destination path that you want. I assume that $search_result[$counter] looks like this - Path\path\path\ABC. You need to get the ABC part of the total path and then do this: DirCopy($search_result[$counter], @Desktopdir & "\ABC", 1) Now the command will create the ABC folder on the desktop and copy over the files within as you wish. You might find this useful to get the folder name from the path: $sPath = "Path\path\path\ABC" $sFolder = StringRegExpReplace($sPath, "^.*\\(.*)", "\1") ConsoleWrite($sFolder & @CRLF) All clear? M23 haha, thanks a lot M23 Works great now this is the modified code, your StringRegExp to get the folder name is so great! $search_result = _RecFileListToArray(GUICtrlRead($location), "*" & $find_criteria & "*", 2, 1, 0, 2) For $counter = 1 to $search_result[0] $folder_name_only = StringRegExpReplace($search_result[$counter], "^.*\\(.*)", "\1") DirCopy($search_result[$counter], @Desktopdir & "\" & @desktopdir & "\" & $folder_name_only, 1) Next Link to comment Share on other sites More sharing options...
michaelslamet Posted March 5, 2011 Share Posted March 5, 2011 michaelslamet, You just need to correctly specify the destination path that you want. I assume that $search_result[$counter] looks like this - Path\path\path\ABC. You need to get the ABC part of the total path and then do this: DirCopy($search_result[$counter], @Desktopdir & "\ABC", 1) Now the command will create the ABC folder on the desktop and copy over the files within as you wish. You might find this useful to get the folder name from the path: $sPath = "Path\path\path\ABC" $sFolder = StringRegExpReplace($sPath, "^.*\\(.*)", "\1") ConsoleWrite($sFolder & @CRLF) All clear? M23 Hi M23, question again The search result, can we know which one is file and which one is folder, if we choose to get both files and folder? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 5, 2011 Moderators Share Posted March 5, 2011 michaelslamet,Read the function header: $sPath - Initial path used to generate filelist. If path ends in \ then folders will be returned with an ending \Then a simple StringRight($var, 1) will let you know. M23P.S. When you reply please use the "Add Reply" button at the top and bottom of the page rather then the "Reply" button in the post itself. That way you do not get the contents of the previous post quoted in your reply and the whole thread becomes easier to read. 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...
michaelslamet Posted March 7, 2011 Share Posted March 7, 2011 Aha, my mistake not reading it carefully And this reply is from "add reply" at the beginning page Thanks, M23!! Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 7, 2011 Moderators Share Posted March 7, 2011 michaelslamet, Delighted I could help. 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...
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