"Can't read file" when trying to Exclude directory in batch file
Asked Answered
K

1

5

I've been stuck on this for awhile and could use some help.

I'm trying to copy a large folder from a mapped network drive (A:) onto my local PC. I also need to exclude a subdirectory on that drive path called "Images". My current code (backup.bat) is below:

cd %HOMEPATH%\Desktop\%mydate%
xcopy "A:\PROGRA~2\QuadTech" 121\ /e /EXCLUDE:"A:\PROGRA~2\QuadTech\INSPEC~1\Images\"

Error I keep getting:

enter image description here

I've tried shortening the path with "dir /x" and I am sure the path name is correct. Also note that I need quotations as there are spaces in the PATH name.

Why am I getting errors when trying to Exclude this directory??

ANSWERED

I now have my Exclude statement point to my desktop where it reads a list of strings in a txt file.

xcopy "A:\PROGRA~2\QuadTech" 121\ /e /EXCLUDE:C:\Users\QuadTech\Desktop\excldelist.txt

Txt file contents:

\Images\
Kylynn answered 7/5, 2017 at 20:10 Comment(2)
have you tried /EXCLUDE:"A:\...\Images\*" ?Kiethkiev
@MikeNakis I have. Gives same error :/Kylynn
K
7

This is happening because the /EXCLUDE option does not specify files to exclude.

It specifies files containing lists of files to exclude.

More info by typing xcopy /?, though I am sure you know that.

(I know, I missed it too in the beginning; sometimes it is just a matter of having a second pair of eyes.)

Kiethkiev answered 7/5, 2017 at 20:42 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.