timdecker Posted January 29, 2016 Share Posted January 29, 2016 I have a list of partial folder names in colB (e.g. "785A5", and the real folder name is "exy-78a5 blah random"). There are about 1500 folders like this. I would like to copy these folders to a new destination. Also, I only keep files in those folders that have a certain prefix, lets call that "indata", and either delete or not copy the other files in that folder. Out of all of that, I really just want to know how to copy folders from one location to another that I have a list of and only partially match. Thanks! Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 29, 2016 Moderators Share Posted January 29, 2016 timdecker, Yet another "I know what I mean but you have to guess" thread. Quote a list of partial folder names in colB What is "colB"? How can you access this data? Quote "785A5", and the real folder name is "exy-78a5 blah random"). That is not a partial name - unless there is a typo in the full name so what exactly is the relationship? Can you provide a few more examples? If you can provide the answers to the above, we might be able to offer some 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...
timdecker Posted January 29, 2016 Author Share Posted January 29, 2016 Sorry, let me clarify. I have a text file that has the following: 3540 3565 3571 3582 3604 3614 I have folders for each of the following: C:\folder\exy-3540 kac\ C:\folder\exy-3565 cda\ etc. I would like to copy the above folders (based on the info in the text file) to another location. Please let me know if I need to clarify anything else. Thanks! Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 29, 2016 Moderators Share Posted January 29, 2016 timdecker, I would read the text file to an array (_FileReadToArray) and then read thesub folders within "C:\folder" to another array (_FileListToArray). Now loop though the first array and see if you can find a suitable partial match within the second (_ArraySearch) - when a match is found you create a suitably named folder in the new location. For each folder found use _FileListToArray with a suitable filter to get an array of the "indata" files you require and copy them over to the newly created folder. Finally delete the original folder. 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...
timdecker Posted January 29, 2016 Author Share Posted January 29, 2016 Thanks M23. I am stuck on the _ArraySearch part. I have my For loop setup, but not sure what to place inside of it to match the arrays and copy the folder. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 29, 2016 Moderators Share Posted January 29, 2016 timdecker, I am assuming the arrays look as follows: Partial Full 3540 C:\folder\exy-3540 kac\ 3565 C:\folder\exy-3565 cda\ So you would need to use something like this: #include <Array.au3> #include <MsgBoxConstants.au3> Global $aPartial[3] = [3540, 3565, 3700] Global $aFull[3] = ["C:\folder\exy-3540 kac\", "C:\folder\exy-3565 cda\", "C:\folder\exy-3800 cda\"] For $i = 0 To UBound($aPartial) - 1 $iIndex = _ArraySearch($aFull, $aPartial[$i], 0, 0, 0, 1) ; $iCompare = 1 executes a partial search If @error Then MsgBox($MB_SYSTEMMODAL, "Error", "No match for: " & $aPartial[$i]) Else MsgBox($MB_SYSTEMMODAL, "Success", "Match for: " & $aPartial[$i] & @CRLF & $aFull[$iIndex]) EndIf Next 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...
timdecker Posted January 29, 2016 Author Share Posted January 29, 2016 Again, thank you M23. I tried to use the following: FileCopy("S:source\" & $aFull[$iIndex] & "\INDATA*.xls", "C:\destination\" & $aPartial[$iIndex], $FC_OVERWRITE + $FC_CREATEPATH) But that did not work out as planned... Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 29, 2016 Moderators Share Posted January 29, 2016 timdecker, So what did happen? And why are you not doing as I suggested above? If you create a new folder, list and copy the relevant files and then delete the old folder I am sure you will find that it works correctly - trying to do it all in one go is just asking for trouble. 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...
timdecker Posted January 29, 2016 Author Share Posted January 29, 2016 Okay. Got it, but I am having an error on the loop: "Array variable has incorrect number of subscripts or subscript dimension range exceeded.:" Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 29, 2016 Moderators Share Posted January 29, 2016 timdecker, Quote I am having an error on the loop And what loop would that be? I presume one in your script - which I have not yet seen - so I cannot offer any sensible advice. 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