PDA

View Full Version : Copy Folder to specified path...



parttime_guy
06-11-2010, 08:53 PM
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.: pray2: :help

Thanks & Best regards

Zack Barresse
06-11-2010, 10:45 PM
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?

shrivallabha
06-11-2010, 10:46 PM
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.

parttime_guy
06-13-2010, 10:30 PM
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

Gollem
06-13-2010, 11:27 PM
Of course this is possible, the web has plenty of examples, here is one of them:

http://www.vb-helper.com/howto_copy_folder_hierarchy.html