Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copy directories (+ contents) with WILDCARDS in source dir name

Status
Not open for further replies.

pvanos

MIS
Jun 6, 2002
73
0
0
BE
Robocopy, XCOPY and all that stuff apparently refuse to accept wildcards in the source directory.
I am looking for a way to copy entire directories, of which the names start with a certain pattern.
This implies the use of a wildcard.
e.g. Robocopy d:\data\ABC* d:\test\ /s

The idea being that any directories within d:\data of which the name is starting with "ABC", would be copied into d:\test\
Including any files or subdirectories that may reside within those ABC-directories.

It is my impression that all copy-utilities only accept wildcards on filename level, but refuse accepting wildcards on the level of directory names.

Any ideas or suggestions ?
 
If I am not mistaken the correct robocopy syntax is as follows;

robocopy d:\data d:\test ABC*.* /s

Hope this helps.
 
This would only copy any FILES starting with "ABC".
I really want all files (no filter on those), but residing within the DIRECTORIES with names starting with "ABC
 
FOUND IT!
No xcopy, xxcopy, robocopy... but a simple .VBScript !
For the example in my first post, this would look like:

Const OverWriteFiles = True
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.CopyFolder "D:\Data\ABC*" , "D:\test" , OverWriteFiles[/color green]

Simply cut-and-paste into Notepad, save as .txt file with extension .vbs, and execute it.

Note: the destination directory needs to exist already, or a message is returned "Microsoft VBScript runtime error: Path not found
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top