EzDevInfo.com

xcopy interview questions

Top xcopy frequently asked interview questions

xcopy files into single directory

I'd like to use xcopy on a Windows machine to pull out all files with .png extension into a single directory.

I tried xcopy C:\folder\*.png /s C:\png\, but it is keeping the sub-directories inside \folder, (for example in C:\png, there is C:\png\a\b\c\img.png) which I don't want. I simply want all .png inside C:\png without it retaining the directory structure that was in C:\folder.


Source: (StackOverflow)

Why is xcopy returning "invalid number of parameters"?

Under some circumstances, xcopy will return the error Invalid number of parameters without giving you a clue as to what’s going on. The usual solution for this is to be sure that your filenames are enclosed in quotes, as this can be an issue with batch files where you have something like xcopy %1 %2 and you really need xcopy "%1" "%2". I recently ran into a problem, however, where the problem wasn't spaces:

C:\Temp\foo>c:/windows/system32/xcopy.exe /f /r /i /d /y * ..\bar\
Invalid number of parameters

Source: (StackOverflow)

Advertisements

Merge directories without overwriting conflicts

I have 2 directories structures (A and B) that normally don't overlap. I want to merge A into B.

The following command will merge the directories:

xcopy A B /E /Y

However, I want to be able to detect conflicts between my 2 directories, and don't overwrite if the file is already at destination (in B). The xcopy will automatically overwrite files. I don't want to be prompted for each conflict (/y). I want to xcopy to return an error on conflict.

The /D option does not work either, because I don't care about the date.

I guess this is not possible with xcopy. Are there other solutions for that?


Source: (StackOverflow)

Windows: File copy/move with filename regular expressions?

i basically want to run:

C:\>xcopy [0-9]{13}\.(gif|jpg|png) s:\TargetFolder /s

i know xcopy doesn't support regular-expression filename searches.

i can't find out how to find out if PowerShell has a Cmdlet to copy files; and if it does, how to find out if it supports regular expression filename matching.

Can anyone think of a way to perform a recursive file copy/move with regex filename matching?


Source: (StackOverflow)

What is the benefit of copy over xcopy on the command line?

I know that xcopy has more options however are there any benefits to using copy rather than xcopy?


Source: (StackOverflow)

Copying many files without stopping on errors on OSX

I need to copy several Gb from an external HD to my moan hd and some files will cause errors. If I do this with the finder, it will stop on the first error.

Is there a way to copy everything no matter the errors? Something like copy of teracopy in Windows?


Source: (StackOverflow)

Is there anyway to xcopy just changed or new files?

I am trying to deploy a website from my desktop to my webserver and so right now I am doing this:

 xcopy C:\source X:\destination /s

My desktop is a Windows XP machine and I need to copy to a Windows Server 2008 machine, but this copies everything and the whole site is very large and it takes a really long time to finish copying.

Is there anyway to specific just copy new or updated files? I see you can pass in a changed since date but I wanted to see if there is a simpler way to compare against destination file...

Also, I am open to using anything outside of xcopy that can do the job as well...


Source: (StackOverflow)

xcopy: move files instead of copy?

I would like to use xcopy to move, not copy files across a network with the Verify flag. I could not find a switch on xcopy to move files, is there an xmove I can use that has verify?

At the moment I am using xcopy /D /V but need to get rid of the files at the source only when it is verified a file was successfully copied to the destination.


Source: (StackOverflow)

How to copy only new files AND only those that are modified after a certain date?

I would like to copy files from one drive to another, but I only want to copy source files that are newer than the destination file. BUT, I also want to only copy source files that have been changed after a certain date.

I know I can use xcopy to do either one of these things, but I would like to do both at the same time.

So for example, I want to copy all source files dated on or after 3/1/2013, but in addition I only want the file copied if the source file is newer than the destination. So ideally I would like to do something like this:

xcopy c:\*.* e:\*.* /D:03-01-2013

combined with something like this:

xcopy c:\*.* e:\*.* /D

Can this be done with xcopy or Robocopy?


Source: (StackOverflow)

Incremental/Differential Backup on Windows

What's the easiet way to perform an incremental/differential backup to a network share in Windows?

Does a Robocopy/Xcopy solution work reasonably well (I need to the parameters!) or is there a good free tool out there that simplifies the management?


Source: (StackOverflow)

XCOPY Behavior copying between remote servers

I am trying to determine the bandwidth usage of XCOPY when copying files between two remote servers.

I am on an XP workstation running a batch file (over a WLAN) which uses XCOPY to copy files from \\server1 to \\server2.

When this copy is run how much file data is actually going through the workstation? Is the workstation actually reading and copying all of files between servers or is the actually copying of the files being handled at the network layer between the servers themselves?

Does Robocopy work the same way?


Source: (StackOverflow)

XCOPY can't read /EXCLUDE file

I'm trying to write a build script batch file for an Unreal Tournament 2004 mod I want to publish the source code for. This script contains a call to XCOPY with the /EXCLUDE parameter as follows:

XCOPY "%ProjectFolder%*" "%BuildFolder%" /S /C /Y /EXCLUDE:"%ProjectFolder%Build\CopyExcludes.cfg"

For some reason that command tells me it cannot read the CopyExcludes.cfg file. How can I fix that?

Within the batch file, %ProjectFolder% is the base folder of the source files, including a trailing backslash. %BuildFolder% is a subfolder within the UT2004 folder where the compiler will expect files to be. I ran the batch file with ECHO ON to see expanded variables:

C:\UT2004>XCOPY "C:\UT2004\EvenMatch\*" "C:\UT2004\EvenMatchV1" /S /C /Y /EXCLUD
E:"C:\UT2004\EvenMatch\Build\CopyExcludes.cfg"
Datei "C:\UT2004\EvenMatch\Build\CopyExcludes.cfg" kann nicht gelesen werden.

0 Datei(en) kopiert

(Nevermind the apparent line break in the command, that's just the CMD window hard-wrapping text after 80 characters.)

The weird part is, I can put the command type "%ProjectFolder%Build\CopyExcludes.cfg" right before and after the XCOPY command and it correctly shows the file content at both positions in the batch file:

C:\UT2004>type "C:\UT2004\EvenMatch\Build\CopyExcludes.cfg"
.svn
.bak
.git
.cfg
#
~

C:\UT2004>XCOPY "C:\UT2004\EvenMatch\*" "C:\UT2004\EvenMatchV1" /S /C /Y /EXCLUD
E:"C:\UT2004\EvenMatch\Build\CopyExcludes.cfg"
Datei "C:\UT2004\EvenMatch\Build\CopyExcludes.cfg" kann nicht gelesen werden.

0 Datei(en) kopiert

C:\UT2004>type "C:\UT2004\EvenMatch\Build\CopyExcludes.cfg"
.svn
.bak
.git
.cfg
#
~

The target folder for XCOPY exists and is empty. Both folders do not have any special access restrictions, at least none that I'm aware of. Process Explorer's find handle feature does not bring up anything when looking for "CopyExclude", i.e. the file doesn't seem to be locked by any other programm. I also already tried copying other subfolders individually, but XCOPY still fails to read the file. According to Notepad++, all lines in the file are terminated with CRLF.

I am using Windows 7 Pro x64, but hopefully can get this to work on any Windows version or edition.


Source: (StackOverflow)

Backing Up from command prompt

I am trying to backup my system from the command prompt as windows will not boot. I only want to backup documents but i am trouble with the command.

I am using "xcopy c:\documents and settings*.doc f:\Backup" and get and error saying the file is not found.

Any suggestions will be appreciated.


Source: (StackOverflow)

Behavior of xcopy when moving files on a network drive

Using a batch file, suppose a directory on a network machine, mapped to a drive with net use.

net use \\"server name"\"share name" y:

Then from that directory

y:
cd archive

An xcopy to another location on that drive.

xcopy *.* backup\

What behaviour would xcopy take? Would a temporary copy of *.* be sent to the host machine (the one on which the batch is started) only to be sent back to the destination directory, or would the copy be effected solely on the network drive?


Source: (StackOverflow)

Use OneDrive as additional backup location

I'm trying to take advantage of the fact that OneDrive now offers unlimited space, and allows these files to not take up space locally. I already have a backup system in place, but I would like to add this as an additional offsite backup option.

My photo folder is 200GB+, and I want it to stay on my data drive, and be available offline. I imagine this is a common scenario.

Goals:

  • Keep my OneDrive on my SSD
  • Keep an offline copy of my files on my data drive
  • Keep an "online-only" copy of my photos in my OneDrive

My first instinct was junction points, but it sounds like they're not supported. Next, I tried Robocopy, but it doesn't like overwriting online-only files.

Is there a way to compare offline files and online-only OneDrive files, and overwrite those files if the source is newer?


Source: (StackOverflow)