how to exlude some extensions to a xcopy in bat

Posted on 2015-02-04
Last Modified: 2015-02-10
Hi i have a bat that put me all the new files to an external 2 TB usb disk

i been infected by ranscrypto and i want to exclude of my backup the  .HLUTBTE extension

is any way to achive that in my .bat file

my bat file is like

echo on
xcopy d:\  H:\  /s /e /D /Y /C

tsm you experts

regards edo
Question by:edo60
LVL 53

Expert Comment

by:Will Szymkowski
ID: 40590120
All you need to do is add the /EXCLUDE switch, like below...
echo on
 xcopy d:\  H:\  /s /e /D /Y /C /EXCLUDE:.HLUTBTE

Open in new window

Below is the exact help from xcopy /?
             Specifies a list of files containing strings.  Each string
             should be in a separate line in the files.  When any of the
             strings match any part of the absolute path of the file to be
             copied, that file will be excluded from being copied.  For
             example, specifying a string like \obj\ or .obj will exclude
             all files underneath the directory obj or all files with the
             .obj extension respectively.


Expert Comment

by:Rezwan Islam
ID: 40590126
Will is right but however I couldn't make it work this way. So I used a text file with all the extensions that needed to be excluded and used the EXCLUDE flag like this instead;


Author Comment

ID: 40590348
Pelase put it in my bat
Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

LVL 84

Accepted Solution

oBdA earned 500 total points
ID: 40590476
I'd use robocopy for that (assuming you're running Vista or later):
robocopy.exe D:\ H:\ *.* /xf *.HLUTBTE /e /r:0 /w:0

Open in new window

Note that robocopy will by default not copy files that already exist in the target folder with the same date and the same size; you'll find those under "skipped" in the summary at the end.

Author Comment

ID: 40592063
exclude do not acept *.hlutubte

cant read *.hlutubte

Author Closing Comment

ID: 40601024

Featured Post

The New “Normal” in Modern Enterprise Operations

DevOps for the modern enterprise offers many benefits — increased agility, productivity, and more, but digital transformation isn’t easy, especially if you’re not addressing the right issues. Register for the webinar to dive into the “new normal” for enterprise modern ops.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will show, step by step, how to integrate R code into a R Sweave document
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question