Reputation: 823
I'm new to Windows batch files, but I'm writing a .bat
file that just copies a bunch of files from one place to another maintaining the file directory structure. Using xcopy
this is simple but I need to exclude some files from being copied. You can use /exclude
and create a text file full of strings that you want to be excluded, but this doesn't just exclude files with the exact names in the text file, it excludes all files whose filenames contain any of the strings in the text file.
What this means is, if I want to exclude any files named 123.txt
and put this string in my exclusions text file, if there was a file called 1123.txt
anywhere in the source folder or any of its subfolders that would also be excluded.
How can I exclude only files with a specific filename from being copied?
Upvotes: 3
Views: 3507
Reputation: 24299
Try creating a temporary folder, xcopy
ing all of the files into that folder, deleting the ones you don't want, then xcopy
ing those to the final destination. Finally, delete the temporary folder and its contents with rd xyzzy /q/s
Upvotes: 0
Reputation: 352
Evening Bill.
Can you add a slash before each file name? That should work
EG
instead of
123.txt
blah.txt
use
\123.txt
\blah.txt
Upvotes: 4