Questions tagged [xcopy]

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

xcopy
Filter by
Sorted by
Tagged with
0 votes
2 answers
35 views

save xcopy error message in a variable in powershell

I want to assign to a variable the error message printed by an xcopy command from a powershell script. If I simply assign the command to a variable, it only saves the last line, where it says the ...
-1 votes
0 answers
31 views

Rename multiple files and a folder based on user input using .bat file [closed]

I have a .bat file which copies some files and folders onto a users PC which in turn creates an Microsoft Outlook email signature. cd xcopy /i /s signature-assets %USERPROFILE%\AppData\Roaming\...
1 vote
2 answers
12k views

batch script if exist xcopy

I need a little help with one batch script and xcopy. I have a folder with a lot of different folders inside. For example: "Test" is the primary directory and inside I have New folder 1, New folder 2, ...
-1 votes
0 answers
55 views

How to copy files to a destination, then delete the source files using a batch file/script?

I'd like a batch file that can copy all files in a source folder to a destination folder, then delete only the source files which copied successfully. The script should overwrite any existing files at ...
1 vote
0 answers
42 views

Not Sure How to Proceed

I am running a NVR on my pc and I create a folder everyday with the date as the folder name like so...(013124) C:/user/profile/videos/013124. At 1202AM I Copy this folder to a network share for backup....
32 votes
5 answers
72k views

Powershell Copy-Item but only copy changed files

I am trying to recurse through a directory and copy it from A to B. That can be done with the following: Copy-Item C:\MyTest C:\MyTest2 –recurse I want to be able though to only copy new files (ones ...
458 votes
24 answers
439k views

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 ...
0 votes
0 answers
23 views

In Windows copy a set of empty folders to a large number of differently-named subfolders

I need to copy three empty folders (named say F1, F2 and F3) to a large number of subfolders. These subfolders are several layers down in a tree of other folders. In other words, I have hundreds of ...
149 votes
16 answers
245k views

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\...
36 votes
7 answers
104k views

Batch file to run xcopy without overwriting existing files

I need my program to run: xcopy s:\* z:\ /E When xcopy runs, it will prompt if a file needs to be overwritten, so I want the batch file to answer no in all cases to the prompt. How can I accomplish ...
82 votes
12 answers
143k views

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 ...
13 votes
3 answers
15k views

SolutionDir set to *Undefined* in post-build xcopy event

I have a project that has a post-build event that xcopies a DLLs to a certain directory: xcopy "$(TargetDir)$(TargetName).dll" "$(SolutionDir)..\UdpLocationService\bin\Plugins\" /d /y xcopy "$(...
14 votes
3 answers
109k views

xcopy returns error "Invalid number of parameters" when exclude parameter is set

Issuing: xcopy X:\ "Y:\...\bin\9876543210\" /c /g /d /i /e /r /h /y works as expected. However: xcopy X:\ "Y:\...\bin\9876543210\" /c /g /d /i /e /r /h /y /exclude:"Y:\...\exclude.txt" returns ...
0 votes
2 answers
3k views

Batch if exists xcopy and create new folder for file

My aim is to locate files on a specified directory copy them and move them to another directory but create a new folder for the files I wish to move. To give some additional information I am moving a ...
2 votes
2 answers
6k views

converting xcopy to robocopy

Tried to use xcopy and excluding a folder and all its subfolders. C:\Merged\org\a>xcopy /I /E /Y C:\Merged\org\*.* C:\Merged\dest /exclude:"C:\Mer ged\org\a\*.*" Can't read file: "C:\Merged\org\a\*...
-1 votes
1 answer
96 views

Default sort order of xcopy

I'm referring to a batch script to create a list of files having file timestamp greater than specified date and store the list of pathnames in a text file. I want to use this to feed a process that ...
13 votes
5 answers
24k views

saving multiple files through xcopy

i want to copy multiple files at once through xcopy. is it possible. i mean something like: xcopy file1+file2+file3 destinationfolder any help is appreciated :)
1 vote
2 answers
14k views

Recursively copy folders with long file names (more than 260 chars)

I am trying to automate copy/replication of drives. Many of the drives have long file names, that fail the process midway. I was using this copy command, but both these fail. XCOPY /E c:\folder-you-...
3 votes
2 answers
30k views

Copying files as administrator in a batch file

So I have a batch file that copies files from one folder to a bunch of different folders. The purpose of this batch file is to be like a simple installer(Without registry edits) to make it easier ...
5 votes
1 answer
2k views

Test IF file exist, ELSE xcopy these two files

Morning all. So I've been up hours trying to cobble together -a variety of replies to other posts- into my own code in order to see if I could get something usable. No-go. I'm sufficiently lost in ...
0 votes
1 answer
376 views

Can't copy folder with permissions to NAS share

I wrote a powershell script that changes the ACL of a network folder. We used to run this script on local drives and on a network share just fine. Recently, we migrated to Windows Server 2019 and ...
91 votes
10 answers
183k views

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,...
0 votes
1 answer
42 views

Invalid number of parameters xcopy

I am creating a pipeline script in my jenkins server(windows). I am trying to copy from SOURCE to DESTINATION using following command. I am getting an error 'invalid number of parameters xcopy /O /X /...
91 votes
9 answers
74k views

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 ...
1 vote
1 answer
3k views

I want to copy a directory excluding one file

I have used the xcopy command with /EXCLUDE switch but for that i have to make another file that contains the list of files to be excluded. Below is the xcopy command i am using... xcopy /EXCLUDE:C:\...
12 votes
4 answers
42k views

Running batch file with arguments from C#

I have a batch file like this @echo off xcopy /e %1 %2 I have my C# code as follows: string MyBatchFile = @"C:\Program Files (x86)\MybatchFile.bat"; string _sourcePath = @"C:\FolderToCopy"; string ...
19 votes
9 answers
84k views

False 'Sharing Violation' Xcopy error message

I am running a batch script (on computer A). The script copies several files from another computer (computer B) to computer A. When the batch script is run, it reports it is unable to xcopy some ...
0 votes
0 answers
49 views

Copy a list of files from a text document

I would like to copy a list of files that I have stored in a text document into a folder. I have been using this script @echo off set src_folder=C:\Source set dst_folder=C:\Destination for /f "...
0 votes
0 answers
24 views

xcopy always override files

this is the situation: File System is corrupt and files are damaged. ChkDsk repaired the filesystem but files are still damaged. So I want to use a Backup and overwrite all files without exception. ...
9 votes
5 answers
25k views

How to use xcopy to add the date in the destination file?

This is my current code xcopy "C:\Users\Asus\Desktop\Test\Test.MDB" "C:\Users\Asus\Google Drive\" /Y /H /E /F /I exit I need the code to do something like: xcopy "C:\Users\Asus\Desktop\Test\Test....
124 votes
14 answers
263k views

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 ...
0 votes
1 answer
40 views

XCopy specific txt files in multiple subfolders without subfolder in path

I have a batch file to copy over files from Web folder to my local folder. Web folder destination look like this: G:\program files\2023\subfolder_1\1.txt G:\program files\2023\subfolder_1\1_total.txt ...
119 votes
2 answers
315k views

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\*.*...
1 vote
3 answers
11k views

Windows xcopy 0 File(s) copied

I am trying to copy a directory but get the following: xcopy ..\node_modules\ \node_modules\ 0 File(s) copied I run as administrator, but still get the error. Any ideas please? p.s I actually ...
-3 votes
2 answers
1k views

Copying files with specific extension from a list (text file) of directories

I have a text file with list of certain directories that I want to copy *.xlsx files from them to another directory. This is how the the text file (list.txt) is arranged: PT_NAK01, PT_NAK04, ...
0 votes
1 answer
1k views

XCopy won't copy from path of the batch script

I have an intune package which runs a batch script as follows. SET INST=%~dp0 xcopy %INST%\Folder1\* "C:\Program Files (x86)\Test\Folder2" /s /i Goal is to copy files from Folder1 to ...
39 votes
7 answers
97k views

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 ...
0 votes
2 answers
2k views

I want to upload only updated files to google drive but XCOPY seems not working

I recently started using Google Drive as a corporate account to backup 10,000+ files. Once I uploaded everything to G:\My Drive\ with taking 3 days. Now for the operation, I would like to copy only ...
0 votes
1 answer
148 views

How to batch copy a list of folders and its file contents from a text file into a new folder in windows

I have a folder with approximately 7000 subfolders. I am interested in copying 1500 of those subfolders and their file contents into a new folder. The closest I have got is copying the subfolders file ...
2 votes
1 answer
125 views

why does the list switch allow xcopy to work?

I have a batch script that uses xcopy to copy a large number of files. For a while, the following setup worked fine: set source=<path_to_source_files> set dest=<path_to_destination> xcopy ...
80 votes
5 answers
176k views

/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 ...
1 vote
1 answer
43 views

Batch File Unable To Compare Two String Variables

The company I work at utilizes a batch file to backup user profiles. The script originally used robocopy, but now also uses xcopy in some cases. We run this script manually when re-imaging users to ...
0 votes
3 answers
446 views

Xcopy folder selection

I would like to make an automated task by using a .bat file in order to copy some files from the server to users' computers. The destination of the files can be on different partitions but the ...
5 votes
2 answers
9k views

bat file commands - how to cut file and replace existing file

I need to swap out a file with data (original) to a dummy file with no data. I need to switch back and forth between these tow files on a regular basis. As a safe way to not delete files, I thought ...
0 votes
1 answer
389 views

Xcopy does not copy file beofre select F for file or D for directory

So I try to copy file via Xcopy with this simple command: xcopy c:\file.doc d:\file.doc And i received this output: Does C:\file.doc specify a file name or directory name on the target (F = file, D = ...
0 votes
1 answer
306 views

Windows Batch File xcopy specific files from same folder

I have a folder that I want to copy several but not all files from, and I am trying to work out how to use a macro for tidy code. For example, the source folder might have 50 files and I want to copy ...
0 votes
1 answer
350 views

using for loop to copy selected files in directory and subdirectories to new directory with the same structure

for /r "C:\Users\bui\Desktop\Annotation Traing Package\test1" %i in (*03.json) do copy "%i" "C:\Users\bui\Desktop\Annotation Traing Package\test2" i want to copy all 03....
0 votes
1 answer
55 views

How do I write a batch programe to copy a set of folders with same suffix and their files from a server to a client?

I want to write a batch program to copy some deeply nested folders with the same suffix in this case 100, It only copied all the folders but only one file in the top most folder (they are ...
0 votes
1 answer
287 views

Batch File to copy files to new directory while renaming, skipping existing files, and without confirmation

I am creating a batch file to be run later which will be used to copy files from one location to another while renaming the files, skipping any existing files, and without prompting the user. Examples ...
2 votes
4 answers
11k views

CMD command line: copy file to multiple locations at the same time

I am trying to use a CMD command prompt to copy a file from one location to multiple at roughly the same time using one line of code. Is there a way to do this using COPY, XCOPY, etc.? I haven't been ...

1
2 3 4 5
16