Find and copy files
-
Ok, I have an excel spreadsheet with partial file names. How does one go about finding a folder with the partial file name. Folders are named like: AB_######_businessname ABC_######_businessname in my spreadsheet I have the ###### What I want to do is go to a directory, find a folder with the ###### in the name, and copy the folder to my destination folder. Help please!!!
-
Ok, I have an excel spreadsheet with partial file names. How does one go about finding a folder with the partial file name. Folders are named like: AB_######_businessname ABC_######_businessname in my spreadsheet I have the ###### What I want to do is go to a directory, find a folder with the ###### in the name, and copy the folder to my destination folder. Help please!!!
not exactly sure what your issue is Surely you are just going to use a combination of FileSystem.GetDirectories() and/or FileSystem.GetFiles() So one approach may be a) (Manually) export the ###### from your spreadsheet to a file, with one ###### per line b) open and read the file from (a) c) for every line read (trim it) and form two strings, one AB_..., one ABC_... d) use GetDirectories() and each of the strings from (c) or, depending on how many ####### variations you have, you could use a regex - get all directories from a root/start point and check if they match (AB|ABC)_(#####1|#####2|#####3...)_businessname using the regex or - read the file of ###### into a list, get a matching list of 'AB*' directories, extract the '######' bit depending on wether its AB or ABC at the front of the string, and see if the ###### bit is in the list there are multiple approaches - I'd probably use the last one, depending on how many ###### there are - if there are 'lots', I might not use a straight list, but something with a faster lookup time 'g'
-
Ok, I have an excel spreadsheet with partial file names. How does one go about finding a folder with the partial file name. Folders are named like: AB_######_businessname ABC_######_businessname in my spreadsheet I have the ###### What I want to do is go to a directory, find a folder with the ###### in the name, and copy the folder to my destination folder. Help please!!!
Here's and example from www.microsoft.com
For Each foundFile As String In My.Computer.FileSystem.GetFiles(
My.Computer.FileSystem.SpecialDirectories.MyDocuments,
Microsoft.VisualBasic.FileIO.SearchOption.SearchAllSubDirectories, "*.dll")Listbox1.Items.Add(foundFile)
Next