Solved

ASimple batch file question

Posted on 2007-04-03
10
230 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
  • 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 142

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
 
LVL 142

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
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.

911 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now