Jump to content


 


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.


Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Photo

xcopy doesn't work


  • Please log in to reply
15 replies to this topic

#1 blockie

blockie

  • Members
  • 10 posts
  • OFFLINE
  •  
  • Local time:04:46 AM

Posted 19 July 2014 - 07:35 PM

I created a .bat file to copy certain folders and files to my backup disk. I don't get any folders or files.

Heres the text to the bat file. Can somebody please tell me what I have done wrong? Incidentally, I run it as Admin.

 

bat text.

xcopy c:\users\william\my documents\myfiles d:\myfiles /y /i /e
xcopy c:\mymacros d:\mymacros /y /i /e
xcopy c:\users\william\my documents\qpdata\*.* d:\qpdata\*.* /y /i /e

close bat text

 

Bill



BC AdBot (Login to Remove)

 


#2 troposphere

troposphere

  • Members
  • 3 posts
  • OFFLINE
  •  
  • Local time:06:46 AM

Posted 19 July 2014 - 08:04 PM

You must put the path names in quotes, such as:

 

xcopy "c:\users\william\my documents\myfiles"   "d:\myfiles" /y /i /e

 

This is because the "my documents" directory name has a space in it.



#3 blockie

blockie
  • Topic Starter

  • Members
  • 10 posts
  • OFFLINE
  •  
  • Local time:04:46 AM

Posted 19 July 2014 - 10:27 PM

I put the quotes in per your answer. The only folder that copied with its file was mymacros and it did not require quotes. Then tried a couple of variations but they didn't work either. Enclosed is the latest bat file. It didn't work either. Do I have the correct attributes?

 

xcopy "c:\users\william\my documents\myfiles" "d:\myfiles" /y /i /e  /s
xcopy c:\mymacros d:\mymacros /y /i /e
xcopy "c:\users\william\my documents\qpdata\*.*" "d:\qpdata\*.*" /y /i /e /s

 

Bill



#4 troposphere

troposphere

  • Members
  • 3 posts
  • OFFLINE
  •  
  • Local time:06:46 AM

Posted 20 July 2014 - 12:08 AM

The other thing I would try is to put "*.*" at the end of your path names as you already have in the last command line.

 

Also, I've never used the "/i" switch mainly because I don't understand what it's for, and I've never had a problem copying things with xcopy.  Try removing the /i.

 

Additionally, the /s is redundant if you are specifying /e.

 

So try:

 

xcopy "c:\users\william\my documents\myfiles\*.*" "d:\myfiles\*.*" /y /e
xcopy c:\mymacros\*.* d:\mymacros\*.* /y /e
xcopy "c:\users\william\my documents\qpdata\*.*" "d:\qpdata\*.*" /y /e



#5 blockie

blockie
  • Topic Starter

  • Members
  • 10 posts
  • OFFLINE
  •  
  • Local time:04:46 AM

Posted 20 July 2014 - 08:57 AM

Tried that too. Didn't work either. I even manually created "myfiles" & "qpdata" on D drive and ran it. Still didn't work. (folder remained empty)

I'll play with it after church and report back

 

Bill



#6 JohnC_21

JohnC_21

  • Members
  • 23,199 posts
  • OFFLINE
  •  
  • Gender:Male
  • Local time:07:46 AM

Posted 20 July 2014 - 09:36 AM

Look at the script here. I believe you have to add Documents and Settings to the line so it would look like this.

xcopy "c:\Documents and settings\%username%\My Documents\myfiles" "f:\myfiles" /s /e

I am not sure but maybe xcopy cannot work using just Users\username. This was added in Windows 7 so a junction point was created, "Documents and Settings", for backward compatibility. But, maybe I am wrong and the above does nothing.




#7 blockie

blockie
  • Topic Starter

  • Members
  • 10 posts
  • OFFLINE
  •  
  • Local time:04:46 AM

Posted 20 July 2014 - 05:01 PM

After church I did the following.
I did a fair amount of troubleshooting why the “XCOPY” command was not copying files and folders to another drive.
So I rewrote it to make the first copies to the same drive.
I noted that the line that copied “mymacros” folder and its file operated OK. It even created a folder first.

So, I moved the “mfiles” folder and its contents to C:\myfiles and then deleted the long path. It worked, created a folder and files.

So, I moved the ”myfiles” folder and its contents to C:\users\myfiles and depleted the rest of the long path. It, again, worked.

I then moved “myfiles” folder to C:\users \william\myfiles and again tried it. It worked again.

So I put the folder “my documents” back into the path and tried it again. It failed this time with the following error, “Invalid number of parameters”.

I then surrounded the path with quotes like this;
xcopy “C:\users\william\my documents\myfiles\*.*”   It failed again with this error, “file not found”.
(left out the destination as that was not giving me a problem)

Now to figure out why the split name (my documents) is giving me the problem and how to fix.

I’ll try the suggestion of JohnC_21.

 

 

Bill



#8 blockie

blockie
  • Topic Starter

  • Members
  • 10 posts
  • OFFLINE
  •  
  • Local time:04:46 AM

Posted 20 July 2014 - 06:16 PM

Tried your suggestion JohnC but I have not looked at the link you provided. Thats next.

 

I can change the Folder with cd C:\Documents and Settings\William\My Documents\myfiles.

 

I then I do a dir and get a list of files in the ......\myfiles\ folder

 

I change the command to  XCOPY “C:\Documents and Settings\William\My Documents\myfiles” and get the error file not found... file myfiles

I then add to myfiles the wild card *.* thusly .....\myfiles\*.*” and get the error file not found... file *.*

I then add to myfiles password.wpd thusly .....\myfiles\password.wpd” and get the error file not found... file password.wpd

Observations:
1. The command dir Gives me a list of files in folder myfiles
2. I thought *.* was a wild card. But XCOPY treats it as a file. See above
3. Password.wpd is in fact in the folder \myfiles\ and it shows with the dir command.

At this point I don’t know what the heck is going on. Why does copying a few files have to be so confusing?


Edited by blockie, 20 July 2014 - 06:18 PM.


#9 troposphere

troposphere

  • Members
  • 3 posts
  • OFFLINE
  •  
  • Local time:06:46 AM

Posted 20 July 2014 - 06:21 PM

I think you're getting the file not found error because in the commands you tried, you only gave one path.

 

Remember you must give a source path and a destination path.



#10 blockie

blockie
  • Topic Starter

  • Members
  • 10 posts
  • OFFLINE
  •  
  • Local time:04:46 AM

Posted 20 July 2014 - 07:52 PM

I did try it with the source and destination. But the trouble was arising in the source so that is what I was concentrated on. I'll try again. But first I will try something else. Although more steps are required I have an idea it might work.

 

"I'll  be baaaack" As our ex-governor use to say.

 

Bill



#11 blockie

blockie
  • Topic Starter

  • Members
  • 10 posts
  • OFFLINE
  •  
  • Local time:04:46 AM

Posted 20 July 2014 - 10:22 PM

Below is the bat file that I thought was a good idea. It fails as soon as the xcopy is invoked. My idea was to move the myfiles and the qpdata folders to the \william\ folder, thereby taking the \my documents\ folder out of the picture. Also, because the \mymacros\ folder copied with out a problem.That is the fourth line in the bat. I then created the \1xfer\ in the root folder of C: drive with the intention of xcopying the entire folder to my external drive later in the bat. But ,alas, I'm still hung up on the xcopy format.

NOTE: the mymacros folder contains only files the other two folders contain sub-folders as well as files

mkdir C:\1xfer\myfiles
mkdir C:\1xfer\mymacros
mkdir C:\1xfer\qpdata
copy c:\mymacros\*.* c:\1xfer\mymacros
xcopy "C:\Documents and Setting\%username%\myfiles\"  "C:\1xfer\myfiles\*.*"  /E /Y

 

Bill



#12 FlannelBack

FlannelBack

  • Members
  • 327 posts
  • OFFLINE
  •  
  • Local time:07:46 AM

Posted 20 July 2014 - 10:30 PM

Try changing this:

xcopy "c:\users\william\my documents\myfiles" "d:\myfiles" /y /i /e  /s

To this:

xcopy "C:\Users\William\Documents\myfiles" "D:\myfiles" /y /e

 



#13 blockie

blockie
  • Topic Starter

  • Members
  • 10 posts
  • OFFLINE
  •  
  • Local time:04:46 AM

Posted 20 July 2014 - 11:03 PM

Thank you FlannelBack,

It worked perfectly. Reduced my workaround that I tried to only three lines. All I did was add  a backslant after the destination folder so I wouldn't have to answer the question of if it were a file or directory every time I ran the batch file.

 

xcopy "C:\Users\William\Documents\myfiles" "D:\myfiles\" /y /e
xcopy "C:\Users\William\Documents\qpdata" "D:\qpdata\" /y /e
xcopy "c:\mymacros" "d:\mymacros\" /y /e

 

Bill



#14 FlannelBack

FlannelBack

  • Members
  • 327 posts
  • OFFLINE
  •  
  • Local time:07:46 AM

Posted 20 July 2014 - 11:11 PM

Glad you've got it working. :thumbsup2:



#15 JohnnyJammer

JohnnyJammer

  • Members
  • 1,117 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:QLD Australia
  • Local time:09:46 PM

Posted 23 July 2014 - 05:52 PM

Personalyli would use RoboCopy as it keps the NTFS permissions in tact.

ROBOCOPY "C:\Users\William\Documents\myfiles" "D:\myfiles\" /E /ZB /DCOPY:T /COPYALL /R:1 /W:1 /V /TEE





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users