Questions tagged [xcopy]

xcopy is a Windows command to copy all files, directories, and subdirectories from a specified path to a target directory

Documentation:

  1. TECHNET
  2. SS64

Related commands:

  1. COPY
  2. ROBOCOPY
797 questions
455
votes
23 answers

xcopy file, rename, suppress "Does xxx specify a file name..." message

This seems pretty simple and maybe I'm just overlooking the proper flag, but how would I, in one command, copy a file from one directory to another and rename it in the destination directory? Here's my command: if exist…
Sarah Vessels
  • 30,930
  • 33
  • 155
  • 222
145
votes
16 answers

What is going wrong when Visual Studio tells me "xcopy exited with code 4"

I'm not very familiar with post-build events, so I'm a little confused as to what's going wrong with my program. When compiling in visual studio 2010, I get the following: The command "xcopy C:\Users\Me\Path\Foo.bar\Library\dsoframer.ocx…
Raven Dreamer
  • 6,940
  • 13
  • 64
  • 101
120
votes
14 answers

Copy files without overwrite

I just can't seem to find a way on the command line to say "copy all the files from directory A to directory B, but if the file already exists in directory B, don't overwrite it, no matter which file is newer, and don't prompt me." I have been…
Tony
  • 1,281
  • 2
  • 11
  • 6
113
votes
2 answers

XCOPY: Overwrite all without prompt in BATCH

I'm writing a batch program for copying all files newer than the destination from "C:\Users\ADMIN\Desktop" to "D:\Backup". This code is works: xcopy "C:\Users\ADMIN\Desktop\*.*" "D:\Backup\" /K /D /H However, it asks for each existing destination…
FZs
  • 16,581
  • 13
  • 41
  • 50
104
votes
6 answers

Why would a post-build step (xcopy) occasionally exit with code 2 in a TeamCity build?

A few projects in my client's solution have a post-build event: xcopy the build output to a specific folder. This works fine when building locally. However, in TeamCity, I occasionally get xcopy [...] exited with code 2 If I use regular copy, it…
Tim Iles
  • 2,232
  • 2
  • 24
  • 26
103
votes
7 answers

XCOPY still asking (F = file, D = directory) confirmation

My batch script xcopy is still asking F = file, D = directory confirmation even though I have added /F in the script, the log is showing as below. Please help on how to avoid asking confirmation. Script: net use p: /delete net use p:…
Testuser
  • 1,107
  • 2
  • 7
  • 15
99
votes
9 answers

How do I find files with a path length greater than 260 characters in Windows?

I'm using a xcopy in an XP windows script to recursively copy a directory. I keep getting an 'Insufficient Memory' error, which I understand is because a file I'm trying to copy has too long a path. I can easily reduce the path length, but…
WestHamster
  • 1,297
  • 2
  • 11
  • 16
90
votes
10 answers

XCOPY switch to create specified directory if it doesn't exist?

I am using XCOPY in a post-build event to copy compiled DLLs from their output folders to the main app's output folder. The DLLs are being copied to a "Modules" subfolder in the main app output folder, like this: xcopy "$(TargetPath)"…
David Veeneman
  • 18,912
  • 32
  • 122
  • 187
83
votes
9 answers

Copy entire directory to output folder maintaining the folder structure?

I want a specific directory to be copied to output folder ("bin") on every build. I think it can be handled via post build scripts. But I'm not sure how to copy a directory itself. I know how to handle specific files. For eg, this works for a…
nawfal
  • 70,104
  • 56
  • 326
  • 368
81
votes
11 answers

Why does the command XCOPY in batch file ask for file or folder?

I have a simple copy from-to script for one of my friends who is missing a file 20 km from my desk. When testing the script out I am prompted if my file shapes.atc is a file or a folder. I can tell you that its a file. How can I automatically copy…
just me
  • 811
  • 1
  • 6
  • 3
77
votes
5 answers

/exclude in xcopy just for a file type

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?…
Matt Dell
  • 9,205
  • 11
  • 41
  • 58
55
votes
6 answers

batch file Copy files with certain extensions from multiple directories into one directory

I'm a newbie, so bear with me... I am trying to copy all .doc files that I have scattered throughout several subdirectories of one main directory into another directory using a batch file. I have managed to get a filelist.txt of all the files…
Brandon
47
votes
3 answers

How to deploy SQL Server Compact Edition 4.0?

How do i deploy Microsoft SQL Server Compact 4.0? SQL Server Compact Edition (currently at version 4.0) is: a free, embedded database that software developers can use for building Windows desktop applications. It has a small footprint and supports…
Ian Boyd
  • 246,734
  • 253
  • 869
  • 1,219
40
votes
10 answers

Why does xcopy exit with code 9009 in Visual Studio post-build step?

I am getting the following error, which I don't understand. Any suggestions? Error 1 The command "xcopy "D:\Users\johndoe\Documents\Visual Studio 2008\Projects\MyProject\MyProject.Modules.Ribbon\bin\Debug\MyProject.Modules.Ribbon.dll" …
David Veeneman
  • 18,912
  • 32
  • 122
  • 187
38
votes
7 answers

Having XCopy copy a file and not overwrite the previous one if it exists (without prompting)

I'm sending commands to a remote computer in order to have it copy a file. I want the file to be copied, but not to overwrite the previous file with the same name (if it exists). I also need the command to run without any prompts (xcopy likes to…
Vic
  • 21,473
  • 11
  • 76
  • 97
1
2 3
53 54