• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Excluding Files from a Copy Command

Excluding Files from a Copy Command

The wildcard characters are used to include multiple files in a single command. But what if you want to exclude certain files? For example, suppose that you have a WP\DOCS folder that has files with various extensions—.doc, .txt, .wp, and so on. What do you do if you want to copy all the files to drive A except those with a .txt extension? One solution is to use separate XCOPY commands for each extension you do need, but that’s too much work (and besides, you might miss some). Instead, try this batch file (named DONTCOPY.BAT):

@ECHO OFF
CLS
ATTRIB +H %1
ECHO.
ECHO Copying all files to %2 except %1:
ECHO.
XCOPY *.* %2
ATTRIB -H %1


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint