Consulting

Results 1 to 5 of 5

Thread: Copy Folder to specified path...

  1. #1

    Copy Folder to specified path...

    Hi All,

    I have a Master Folder on my C-Drive.

    I need to copy this Master Folder (including all its contents) into all sub-folders (there are 150+ sub-folders) on a network drive.

    Is this possible via VBA.

    Kindly help.

    Thanks & Best regards

  2. #2
    Site Admin
    Urban Myth
    VBAX Guru
    Joined
    May 2004
    Location
    Oregon, United States
    Posts
    4,940
    Location
    Hello there,

    Can you please specify a little more what your requirements are exactly? Your question is a little ambiguous as to the destination folder(s). Are you saying you want to copy one single folder (all contents plus sub folders) into 150 other separate folders on a network drive? Is this for a backup? And if for a backup, there are a lot of programs out there that does this natively - what they're designed for actually. Are you sure you want to do this via VBA?

  3. #3
    VBAX Expert shrivallabha's Avatar
    Joined
    Jan 2010
    Location
    Mumbai
    Posts
    750
    Location

    Scheduled Task + Bat file

    Do you really need VBA for that?
    You can create a Run.bat file using XCOPY.
    C:\>help xcopy
    Copies files and directory trees.
    
    XCOPY source [destination] [/A | /M] [/D[:date]] [/P] [/S [/E]] [/V] [/W]
                               [/C] [/I] [/Q] [/F] [/L] [/G] [/H] [/R] [/T] [/U]
                               [/K] [/N] [/O] [/X] [/Y] [/-Y] [/Z]
                               [/EXCLUDE:file1[+file2][+file3]...]
    
      source       Specifies the file(s) to copy.
      destination  Specifies the location and/or name of new files.
      /A           Copies only files with the archive attribute set,
                   doesn't change the attribute.
      /M           Copies only files with the archive attribute set,
                   turns off the archive attribute.
      /D:m-d-y     Copies files changed on or after the specified date.
                   If no date is given, copies only those files whose
                   source time is newer than the destination time.
      /EXCLUDE:file1[+file2][+file3]...
                   Specifies a list of files containing strings.  Each string
                   should be in a separate line in the files.  When any of the
                   strings match any part of the absolute path of the file to be
                   copied, that file will be excluded from being copied.  For
                   example, specifying a string like \obj\ or .obj will exclude
                   all files underneath the directory obj or all files with the
                   .obj extension respectively.
      /P           Prompts you before creating each destination file.
      /S           Copies directories and subdirectories except empty ones.
      /E           Copies directories and subdirectories, including empty ones.
                   Same as /S /E. May be used to modify /T.
      /V           Verifies each new file.
      /W           Prompts you to press a key before copying.
      /C           Continues copying even if errors occur.
      /I           If destination does not exist and copying more than one file,
                   assumes that destination must be a directory.
      /Q           Does not display file names while copying.
      /F           Displays full source and destination file names while copying.
      /L           Displays files that would be copied.
      /G           Allows the copying of encrypted files to destination that does
                   not support encryption.
      /H           Copies hidden and system files also.
      /R           Overwrites read-only files.
      /T           Creates directory structure, but does not copy files. Does not
                   include empty directories or subdirectories. /T /E includes
                   empty directories and subdirectories.
      /U           Copies only files that already exist in destination.
      /K           Copies attributes. Normal Xcopy will reset read-only attributes.
      /N           Copies using the generated short names.
      /O           Copies file ownership and ACL information.
      /X           Copies file audit settings (implies /O).
      /Y           Suppresses prompting to confirm you want to overwrite an
                   existing destination file.
      /-Y          Causes prompting to confirm you want to overwrite an
                   existing destination file.
      /Z           Copies networked files in restartable mode.
    
    The switch /Y may be preset in the COPYCMD environment variable.
    This may be overridden with /-Y on the command line.
    And then schedule that task.
    Regards,
    --------------------------------------------------------------------------------------------------------
    Shrivallabha
    --------------------------------------------------------------------------------------------------------
    Using Excel 2016 in Home / 2010 in Office
    --------------------------------------------------------------------------------------------------------

  4. #4
    Hi Zack & Sri,
    Thx for showing interest...

    I have a Master Folder on my C-Drive. The Master Folder contains some formats (including sub-folders) that are used by various users.

    I need to copy paste all formats (including sub-folders) from my C-Drive into the Client Folders on the network Drive (there are 150+ client folders on the network Drive).

    These formats files on the C-Drive are updated regularly - so all the format files have to updated on a regular basis. Currently we are using the share folder system.

    Can VBA automate this process? So all the Client Folder will have the latest formats.

    Kindly Help
    Thx & BR

  5. #5
    VBAX Regular
    Joined
    Oct 2004
    Location
    Belgium
    Posts
    25
    Location
    Of course this is possible, the web has plenty of examples, here is one of them:

    http://www.vb-helper.com/howto_copy_...hierarchy.html

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •