Solved

XCOPY failure on 'My Documents' folder on Windows 7

Posted on 2010-08-17
13
952 Views
Last Modified: 2012-05-10
Hi,

I use a batch file to backup a user's files from a laptop hard drive (c:) to a mapped drive (z:) on a desktop pc . The desktop is running Windows XP but this particular laptop has Windows 7. I've never had a problem until using this Win7 laptop.

The batch file attached copies 2 folders but it fails on the second xcopy command with 'file not found - *.*'. The only conclusion I've arrived at after trying endless combinations / variations on the command is that Windows 7 doesn't like the folder name 'my documents' with a space in it as other folders copy fine. It also seems to work fine when entered directly at a dos prompt?

(I also noticed some seemingly intermittent problems copying files across manually using dos and drag/drop in explorer, with Windows hanging for long periods. I disabled the windows 7 feature called remote differential compression which may have solved that issue.)

Any ideas please on how to solve this seemingly trivial task?
Thanks.
echo ----------
echo Backing up Local Desktop..
echo .
c:
cd "\users\BDM\desktop"
z:
cd "\BDM\desktop"
xcopy c:*.* /d/s/y

echo ----------
echo Backing up Local Documents..
echo .
c:
cd "\users\BDM\my documents"
z:
cd "\BDM\my documents"
xcopy c:*.* /d/s/y

Open in new window

0
Comment
Question by:nigelr99
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 2
  • +4
13 Comments
 
LVL 42

Expert Comment

by:sedgwick
ID: 33453903
try xcopy "c:*.*" /d/s/y
0
 
LVL 3

Expert Comment

by:MaSTeRiTo
ID: 33453941
soooo ... Z: is your mapped network location?
Try:

xcopy "c:\full path\to desktop\folder" "z:\users\BDM\desktop" /options
xcopy "c:\full path\to docs\folder" "z:\users\BDM\my docs" /options

It looks like you're trying to copy your full c: drive
The error might come from your in use files there (ie page file)
0
 
LVL 5

Accepted Solution

by:
ploftin earned 125 total points
ID: 33453985
In Windows 7, the folder you should be accessing to copy documents from is: C:\Users\USERNAME\Documents   Change your batch file to copy from there for the second folder and you should be good.
0
Is Your DevOps Pipeline Leaking?

Is your CI/CD pipeline a hodge-podge of randomly connected tools? You’ve likely got a tool to fix one problem & then a different tool to fix another, resulting in a cluster of tools with overlapping functionality. Learn how to optimize your pipeline with Gartner's recommendations

 

Author Comment

by:nigelr99
ID: 33453994
I've already tried "c:*.*" to no avail.

I'm only copying a particular folder on the c drive as I've changed directory previous to the xcopy command as follows:
          c:
          cd "\users\BDM\my documents"

If there was a file open, would this give the 'file not found' error? When first tested there was only one file in the 'my documents' folder so pretty sure this wasn't an issue.
0
 
LVL 8

Expert Comment

by:ConUladh
ID: 33453999
xcopy "C:\users\BDM\my documents\*.*" "z:\users\BDM\my documents" /d/s/y
0
 
LVL 5

Expert Comment

by:ploftin
ID: 33454002
Further clarification:

Do it like this:
echo ----------
echo Backing up Local Desktop..
echo .
c:
cd "\users\BDM\desktop"
z:
cd "\BDM\desktop"
xcopy c:*.* /d/s/y

echo ----------
echo Backing up Local Documents..
echo .
c:
cd "\users\BDM\documents"
z:
cd "\BDM\documents"
xcopy c:*.* /d/s/y

Open in new window

0
 
LVL 2

Expert Comment

by:ghemstrom
ID: 33454045
What happens if there is not a single file according to the /d condition in any directory addressed?
0
 
LVL 2

Expert Comment

by:Comtek
ID: 33454155
MaSTeRiTo,

Using C:*.* will copy the current folder, using C:\*.* will copy the entire drive. The key is the backslash (\) afer the colon (:).

nigelr99,

What MaSTeRiTo said should almost work for you. One thing to note is that the actual folder name for your user docs is "Documents", not "My Documents". Or more specifically, use this:

echo ----------
echo Backing up Local Desktop..
echo .
xcopy "c:\users\BDM\Desktop" "z:\BDM\Desktop" /d/s/y

echo ----------
echo Backing up Local Documents..
echo .
xcopy "c:\users\BDM\Documents" "z:\BDM\my documents" /d/s/y

Open in new window

0
 
LVL 2

Expert Comment

by:Comtek
ID: 33454161
I tested the above script on my WIndows 7 machine and it worked perfectly.
0
 
LVL 2

Expert Comment

by:ghemstrom
ID: 33454239
The same solution should be used for Vista also!
0
 

Author Comment

by:nigelr99
ID: 33454516
Just checked the Win7 machine and path is definitely c:\users\BDM\my documents.  I've attached a screen-shot just to make sure I'm not going mad.

I tried xcopy "c:\users\BDM\My Documents" "z:\BDM\my documents" /d/s/y

..but I get the same error.. something funny going on here right?

Update... I renamed the 'my documents' folder to 'documents' and script works fine.. sometimes you get to the stage when you don't care why any more!

win7-screenshot.PNG
0
 
LVL 2

Assisted Solution

by:Comtek
Comtek earned 125 total points
ID: 33454543
Look at it from the command prompt and you will see that's it's actually called "Documents".


cmd.jpg
0
 

Author Closing Comment

by:nigelr99
ID: 33454648
The penny's finally dropped.. different folder names in explorer and dos! I knew it would be something simple if not illogical.
Thanks ploftin and Comtek.. you've highlighted the problem so I'll share the points. Thanks!
Cheers.
0

Featured Post

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you get continual lockouts after changing your Active Directory password, there are several possible reasons.  Two of the most common are using other devices to access your email and stored passwords in the credential manager of windows.
When you try to share a printer , you may receive one of the following error messages. Error message when you use the Add Printer Wizard to share a printer: Windows could not share your printer. Operation could not be completed (Error 0x000006…
In this video, we discuss why the need for additional vertical screen space has become more important in recent years, namely, due to the transition in the marketplace of 4x3 computer screens to 16x9 and 16x10 screens (so-called widescreen format). …
This Micro Tutorial will teach you how to the overview of Microsoft Security Essentials. This is a free anti-virus software that guards your PC against viruses, spyware, worms, and other malicious software. This will be demonstrated using Windows…

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question