Solved

ASimple batch file question

Posted on 2007-04-03
10
234 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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

Issue: Unstable cursor in Windows XP and Windows runs extremely slow in that any click will bring up the Hour glass (sometimes for several seconds before giving you what you want) . Troubleshooting Process and the FINAL FIX: This issue see…
If like me you are one who spends a lot of time working and scripting with cmd.exe, sometimes it is handy to be able to quickly view a calendar for a given month and year. This script will quickly do just that!  Save the code posted below to a .bat …
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…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

732 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