Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3441424
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T08:33:05+00:00 2026-05-18T08:33:05+00:00

I have a batch file to copy over files from Visual Studio to my

  • 0

I have a batch file to copy over files from Visual Studio to my Web folder. I want to copy all files in my web project, EXCEPT for *.cs files. I can’t seem to get this to work:

xcopy /r /d /i /s /y /exclude:".cs" C:\dev\apan C:\web\apan

Any tips? I just get exit code 4 when I try to run this.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T08:33:06+00:00Added an answer on May 18, 2026 at 8:33 am

    The /EXCLUDE: argument expects a file containing a list of excluded files.

    So create a file called excludedfileslist.txt containing:

    .cs\
    

    Then a command like this:

    xcopy /r /d /i /s /y /exclude:excludedfileslist.txt C:\dev\apan C:\web\apan
    

    Alternatively you could use Robocopy, but would require installing / copying a robocopy.exe to the machines.

    Update

    An anonymous comment edit which simply stated "This Solution exclude also css file!"

    This is true creating a excludedfileslist.txt file contain just:

    .cs
    

    (note no backslash on the end)

    Will also exclude all of the following:

    • file1.cs
    • file2.css
    • dir1.cs\file3.txt
    • dir2\anyfile.cs.something.txt

    Sometimes people don’t read or understand the XCOPY command’s help, here is an item I would like to highlight:

    Using /exclude

    • List each string in a separate line in each file. If any of the listed strings match any part of the absolute path of the file to be copied, that file is then excluded from the copying process. For example, if you specify the string "\Obj", you exclude all files underneath the Obj directory. If you specify the string ".obj", you exclude all files with the .obj extension.

    As the example states it excludes "all files with the .obj extension" but it doesn’t state that it also excludes files or directories named file1.obj.tmp or dir.obj.output\example2.txt.

    There is a way around .css files being excluded also, change the excludedfileslist.txt file to contain just:

    .cs\
    

    (note the backslash on the end).

    Here is a complete test sequence for your reference:

    C:\test1>ver
    
    Microsoft Windows [Version 6.1.7601]
    
    C:\test1>md src
    C:\test1>md dst
    C:\test1>md src\dir1
    C:\test1>md src\dir2.cs
    C:\test1>echo "file contents" > src\file1.cs
    C:\test1>echo "file contents" > src\file2.css
    C:\test1>echo "file contents" > src\dir1\file3.txt
    C:\test1>echo "file contents" > src\dir1\file4.cs.txt
    C:\test1>echo "file contents" > src\dir2.cs\file5.txt
    
    C:\test1>xcopy /r /i /s /y .\src .\dst
    .\src\file1.cs
    .\src\file2.css
    .\src\dir1\file3.txt
    .\src\dir1\file4.cs.txt
    .\src\dir2.cs\file5.txt
    5 File(s) copied
    
    C:\test1>echo .cs > excludedfileslist.txt
    C:\test1>xcopy /r /i /s /y /exclude:excludedfileslist.txt .\src .\dst
    .\src\dir1\file3.txt
    1 File(s) copied
    
    C:\test1>echo .cs\ > excludedfileslist.txt
    C:\test1>xcopy /r /i /s /y /exclude:excludedfileslist.txt .\src .\dst
    .\src\file2.css
    .\src\dir1\file3.txt
    .\src\dir1\file4.cs.txt
    3 File(s) copied
    

    This test was completed on a Windows 7 command line and retested on Windows 10 "10.0.14393".

    Note that the last example does exclude .\src\dir2.cs\file5.txt which may or may not be unexpected for you.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using a batch file to concatenate all my css files copy /b reset.css+action-plan.css+buttons.css+behaviours.css+footer.css+forms.css+header.css+home.css+layout.css+lightbox.css+print.css+questionnaire.css+typography.css+you-told-us.css
I need to have a batch file that copies files (8) in my local
i want to copy a file (example: a.jpg) to all folders in a directory.
I have a batch file (in windows XP, with command extension activated) with the
I have a batch file that was created for an Oracle database that I'm
For example, suppose I have a batch file called 'test.cmd' and it simply contains:
Is there any way to have a Windows batch file directly input SQL statements
I have a service that sometimes calls a batch file. The batch file takes
While running a batch file in Windows XP I have found randomly occurring error
I would like a batch file to launch two separate programs then have the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.