Link to home
Create AccountLog in
Avatar of elwayisgod
elwayisgodFlag for United States of America

asked on

MS DOS/Windows Batch - Copy all directories bu exclude files that end with .pag or .ind

Hi,

I need to copy a directory and all its subfolders and files.  However I need it to NOT copy any file ending in .pag or .ind.   I usually  use xcopy but can't figure out how to skip certain files....

Avatar of sirbounty
sirbounty
Flag of United States of America image

use the
/EXCLUDE *.pag +*.ind
parameter...
You need to create a text file with the file extensions you wish to exclude. The file is very simple and yours should include the following:
.pag
.ind

Thats it. Save as exclusions.txt, then run xcopy with the /EXCLUDE:exclusions.txt argument at the end of the command, that should do it.
Avatar of mikewurtz
mikewurtz

Use robocopy.exe.  It's included with Vista and Server 2003 or you can download it from Microsoft for XP computers.

Use /E to copy all subdirectories and files.

Use the "/XF *.pag *.ind" option to exlude files with those extensions.
If you create a file with contents:

.pag
.ind

and feed this file into /exclude argument of xcopy, it should work!
Avatar of elwayisgod

ASKER

CorruptedLogic:

I'm trying your solution with a file named 'xcopy_exclude.txt'.  That file is:

*.ind
*.pag

Then I run the below and nothing is copied it just scrolls really fast.....

xcopy "X:\EssbaseBackup\Weekly\Mon\" "I:\Newmont\Mon\" /Y /S /E /i /EXCLUDE:xcopy_exclude.txt
X:\ is a mapped drive on my laptop to our server.  I:\ is a usb drive plugged into my laptop.  Does that make a difference?
Does Xcopy even work on XP?
ASKER CERTIFIED SOLUTION
Avatar of sirbounty
sirbounty
Flag of United States of America image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Ditto to what sirbounty suggests. Unless the xcopy_exclude.txt file is in the same folder you run the command from, it will not be found (unless you add that folder to your path statement, but that's another story :o) )