Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Find and copy files

Find and copy files

Scheduled Pinned Locked Moved Visual Basic
help
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    big_D
    wrote on last edited by
    #1

    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!!!

    G E 2 Replies Last reply
    0
    • B big_D

      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!!!

      G Offline
      G Offline
      Garth J Lancaster
      wrote on last edited by
      #2

      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'

      1 Reply Last reply
      0
      • B big_D

        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!!!

        E Offline
        E Offline
        Eldar Zeynalov
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups