I have to write a batch file that will copy folder sturcture, folder contents, whilst exlcuding some folders from the exisiting directory.
what i have so far is the following
\1111
\1112\ <----ie the folders i dont want to copy
I got most of this from Google, but cannot seem to get it to work.
basicly i have 4-500 folders all named with either four or 5 digits which need to go from one server to another. There are also in this holding Dir about 6-7 folders with a large amount of data within them which i do not want to copy, tho these folders do not follow the same four or five digit naming convention.
/T Creates directory structure, but does not copy files. Does not
include empty directories or subdirectories. /T /E includes
empty directories and subdirectories.
try putting your action parameters after the where-from-to logic and juggle the action parameters into the order expected if you want the full list just do… " xcopy /? "
Just done some testing myself. Removing the /t on the original line only shows copying of files, but it does create any empty directories too even if it doesn’t list them (due to /e).
Also I think I found out why the exclusions didn’t work. xcopy uses pattern matching on the path. The exclusion pattern doesn’t match if you use a relative path from current directory. Instead use full path, it seems to work.
Spaceboy, zip might be an option, only prob is that it needs to be as quick as possible, for its going to be moving about 500 6meg files, and if i can just move them without any other processing then that would be best.
PMM - are you saying that i just have it the wrong way round?
Mackerel, are you saying that in my exclusions file i need the full direcotry path and not just the names ? for your EG looks remarkably simular to my own example?
Nope. You have two choices:
Specify the full source path on the xcopy command, not use relative or current.
Specifically use something like
xcopy /h /r /k /x /y /e [b]d:\somewhere[/b]. c:\ /exclude:c: emp\1.txt
not
xcopy /h /r /k /x /y /e . c:\ /exclude:c: emp\1.txt
As the original command without /k stood, it would generate paths in the format of c:folder\file.ext - note there is no leading \ so the pattern does not match. If you use the full source, it seems to then use the format of c:\somewhere\folder\file.ext and file matching works.
Alternatively you could specify the exclusions without the leading \ so that patterns will match regardless, but that might match other directory names at the end so might include more than you want. e.g. excluding ‘\1234’ would only match ‘\1234’ but ‘1234’ might also match ‘\01234’