Application of Xcopy command line not working on Win 7

May 24, 2015 at 22:48:42
Specs: Windows 7
Hi,

I'm trying to run xcopy Exclude. but it not working. I used it like below :

xcopy c:\other\A\ABC\** C\other\B\ABC\** /Exclude:name.exe

but it giving error : File not found


See More: Application of Xcopy command line not working on Win 7

Report •

#1
May 25, 2015 at 02:21:36
xcopy is working but it's simply telling you that the file doesn't exist in that path.

Check that the file actually exists in the source path you used in the xcopy command.

Or make sure the source path you used in the xcopy command is correct.

message edited by phil22


Report •

#2
May 25, 2015 at 04:11:33
Sorry i mentioned wrong error earlier.

Error i'm getting is "Can't read file"
though file exists in the source folder.


Report •

#3
May 25, 2015 at 04:45:38
Possibly as there is a colon ( : ) missing the destination section?

Your command (as posted here):

xcopy c:\other\A\ABC\** C\other\B\ABC\** /Exclude:name.exe

perhaps ought to be:

xcopy c:\other\A\ABC\** c:\other\B\ABC\** /Exclude:name.exe

The case for c:\ isn't critical as I recall; can be upper or lower case?


Report •

Related Solutions

#4
May 25, 2015 at 06:27:02
What is the meaning of ** or do you mean *.*?

Report •

#5
May 25, 2015 at 06:36:07
Xcopy and its Application
http://commandwindows.com/xcopy.htm

Report •

#6
May 25, 2015 at 06:56:31
looks like another error in the syntax - as it sluc points out - is the ** meant to be *
.* (meaning any/all files...)?

message edited by trvlr


Report •

#7
May 25, 2015 at 09:17:26
sluc: "Match anything, followed by anything" (**) is functionally equivalent to "match anything with any extension" (*.*), as well as "match anything" (*).

trvlr: Nice catch with the missing colon, but that wouldn't generate an error message. XCOPY would just create a subdirectory called "C."

moni11: the /EXCLUDE switch does not tell XCOPY which files to exclude. It tells XCOPY where to find a file list for exclusion.

> exclude.txt echo name.exe
xcopy c:\other\A\ABC\** C\other\B\ABC\** /Exclude:exclude.txt
del exclude.txt

How To Ask Questions The Smart Way

message edited by Razor2.3


Report •

#8
May 25, 2015 at 09:34:39
With the passing of thyme... the "how to use and (misuse)" of Xcopy starts to fade...

All to0 easy these days with point 'n click...

message edited by trvlr


Report •

#9
May 27, 2015 at 20:25:01
My bad..c: was just a typo mistake..

XCopy /e /v /y c:\Other\A\Eve\** c:\Other\B\Eve\** /EXCLUDE:name.exe

This is still not working..
throwing same error Can't read file: name.exe

Razor2.3 : I tried writing the exe in the text file also, but still getting the same error :

C:\Other\A>XCopy c:\Other\A\Eve\** c:\Other\B\Eve\** /EXCLUDE:My.txt
Can't read file: My.txt

message edited by moni11


Report •

#10
May 27, 2015 at 22:06:28
This is a long shot but are there any spaces in the folder or file names? If so, put quote marks around the path.

IE. "C:\space in folder name\space in file name.exe"

message edited by THX 1138


Report •

#11
May 27, 2015 at 22:26:23
No space in the folder or file name.

tried putting quotes too, still the same error.


Report •

#12
May 27, 2015 at 22:54:17
Reading is an art.
As already explained by Razor in #7, what follows the /EXCLUDE: is a TEXT file(s)containing the file names or patterns to be excluded.

Is "names.exe" a text file??


Report •

#13
May 27, 2015 at 23:03:28
tried putting text file too earlier...but that also didn't work.

Tried following ways :
1. by giving text file without extensiom
C:\Other\A>xcopy c:\Other\A\Eve\** c:\Other\B\Eve\** /EXCLUDE:My
Can't read file: My

2. by giving text file with extension
C:\Other\A>xcopy c:\Other\A\Eve\** c:\Other\B\Eve\** /EXCLUDE:My.txt
Can't read file: My.txt

3. by giving full text file path
C:\Other\A>xcopy c:\Other\A\Eve\** c:\Other\B\Eve\** /EXCLUDE:c:\Other\A\My.txt
Can't read file: c:\Other\A\My.txt

4. By giving text file path with quotes

C:\Other\A>xcopy c:\Other\A\Eve\** c:\Other\B\Eve\** /EXCLUDE:"c:\Other\A\My.txt
"
Can't read file: "c:\Other\A\My.txt"

Nothing worked.
My machine is Win 7, is there any issues with xcopy on Win 7 or there is some issue in the way i'm writing.


Report •

#14
May 28, 2015 at 00:41:07
Have you tried *.

Report •

#15
May 28, 2015 at 00:44:03
where should i write *. in exclude.

Can you please provide me complete command based on my above command.


Report •

#16
May 28, 2015 at 00:59:55
Experiment.

Replace one or both **


Report •

#17
May 28, 2015 at 01:01:50
tried that also. didn't work

Report •

#18
May 28, 2015 at 04:22:38
You'll notice my example was 3 lines long. You're missing 2 of them.

How To Ask Questions The Smart Way


Report •

#19
May 28, 2015 at 19:41:45
Razor : It is giving me Error if i'm trying to execute the commands you mentioned in your previous post:

Following is the error :

C:\Other\A>Exclude.txt echo Eve.exe
'Exclude.txt' is not recognized as an internal or external command,
operable program or batch file.

message edited by moni11


Report •

#20
May 28, 2015 at 19:56:22
" those lines :"
That doesn't tell Razor2.3 you are using 3 lines.

Report •

#21
May 28, 2015 at 21:13:45
In post #7, Razor2.3 wrote:
__________________________________________________
the /EXCLUDE switch does not tell XCOPY which files to
exclude. It tells XCOPY where to find a file list for exclusion.

> exclude.txt echo name.exe
xcopy c:\other\A\ABC\** C\other\B\ABC\** /Exclude:exclude.txt
del exclude.txt
__________________________________________________

The first command gave moni11 trouble. Obviously Razor2.3
intended to create a file named "exclude.txt" containing the text
"name.exe". The command to do that is:

echo "name.exe" > exclude.txt

Razor had the correct parts but somehow put them in the wrong order,
probably in editing. I'm not sure the quotes are always necessary, but
they work.

moni11,

I expect that you will create a text file using a method other than echo.
But you need to create that text file containing the names of the files
you want to exclude.

-- Jeff, in Minneapolis

message edited by Jeff Root


Report •

#22
May 28, 2015 at 22:30:30
Thanks alot Razor /Johnw/Jeff. Finally this worked with the solution provided by using echo command to create file at run time. :)

Many thanks.


Report •

#23
May 28, 2015 at 23:07:44
This is working if i directly run on the command prompt. But it is not working via running it in PostBuild batch file.

It is not giving any error there...but also not doing anything.


Report •

#24
May 29, 2015 at 00:17:09
It worked. But i'm facing one issue.

This exclude command is not looking at exact file name.
Like in my case..i was to exclude just name.exe file. But in my folder i have one more file called name.exe.config. This file is also getting excluded which i don't want.

Do you have any suggestion on this?


Report •

#25
May 29, 2015 at 00:47:12
Found the solution.
Writing the command like below worked.

echo \name.exe\ > exclude.txt


Report •

#26
May 29, 2015 at 07:38:02
Jeff Root:
It's odd syntax, and it doesn't look like it should work, but it does, and it prevents the space between the file name, and end of line. Turns out CMD will accept a ">" anywhere in the command, and immediately looks for the file path, then continues to process the rest of the command unabated.

Case in point:

M:\>echo Hello > output.txt World

M:\>type output.txt
Hello  World

M:\>

How To Ask Questions The Smart Way


Report •

#27
May 29, 2015 at 15:18:24
Interesting and surprising.

In addition, it appears I was wrong about using quotation marks.
I tested it (once) and thought the quotes did not show up in the
text file. I try again now, and they show up (where I didn't want
them to show up).

So in reply #19, moni11 should have typed a "greater than"
character immediately after the input prompt (which by default
ends with a "greater than" character), followed by a space, and
then everything he actually typed. Instead of:

C:\Other\A>Exclude.txt echo Eve.exe

he should have had:

C:\Other\A>> Exclude.txt echo Eve.exe

He should be able to eliminate the two backslashes he used to
replace the quotation marks I mistakenly added.

-- Jeff, in Minneapolis

message edited by Jeff Root


Report •

Ask Question