Solved

ASimple batch file question

Posted on 2007-04-03
10
233 Views
Last Modified: 2010-04-16
Im trying to learn to write batch files primarily for backup purposes. I'd like to create a custom batch file for a few employee's who are not capble of backing their files up. So Im reading about it and trying some different things with limited sucess. I understand most of the switches.
Is there something special needed to go to say C:\Documents and settings\John Doe\My Documents because it doesn't work for me. However C:\Dell would.

Heres one that works:
xcopy /e /v /y C:\dell E:\Music
Heres one that doesn't:
xcopy /e /v /y C:\Documents and Settings\John Doe\My Documents E:\John Doe

Is it a folder attribute? A needed switch? Is there an easy way to learn\test batch files?
0
Comment
Question by:zen_68
[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
  • 4
  • 2
  • 2
  • +1
10 Comments
 
LVL 67

Accepted Solution

by:
sirbounty earned 250 total points
ID: 18845823
Spaces need to be enclosed in quotes:

xcopy /e /v /y "C:\Documents and Settings\John Doe\My Documents" E:\John Doe
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 18845826
for folders with spaces, use double quotes around it:

xcopy /e /v /y "C:\Documents and Settings\John Doe\My Documents" "E:\John Doe"
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 18845834
Or, you can use the short-version:

xcopy /e /v /y C:\Docume~1\JohnDo~1\MyDocu~1 E:\John Doe

or, if it's the currently logged on user,

xcopy /e /v /y "%userprofile%\My Documents" E:\John Doe
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 18845835
sirbounty, you were faster, but this time too fast :-)   you overlooked the last space ---
CHeers
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 18845841
Guess that first comment: "Spaces need to be enclosed in quotes:"
saved me, eh? lol :^)
0
 
LVL 32

Expert Comment

by:and235100
ID: 18845878
I wouldn't use xcopy at all.

Use robocopy - http://www.ss64.com/nt/robocopyXP.html

It has far many more options than xcopy - and is a preferred command for batch files...
0
 

Author Comment

by:zen_68
ID: 18846017
Thanks for the help guys.
Im guessing I'll be back..lol
0
 

Author Comment

by:zen_68
ID: 18846021
And I'll give robocopy a try.
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 18846028
Thanx. :^)
0
 
LVL 32

Expert Comment

by:and235100
ID: 18846036
Mmm - as I said before - xcopy is not the best answer - but I suppose - it is up to you, zen_68...
0

Featured Post

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Copy dir and files with robocopy 2 72
Bat File Script - HELP 2 34
Renaming with batch file 9 77
BATCH find highest numbered .jpg and save in a variable ? 2 19
Being a system administrator some time we require to do things remotely, one of them is installing software. Here I am going to tell you how to install software through wmic (Windows management instrument console). I am not at all saying that this i…
Introduction: Recently, I got a requirement to zip all files individually with batch file script in Windows OS. I don't know much about scripting, but I searched Google and found a lot of examples and websites to complete my task. Finally, I was ab…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

735 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