Solved

ASimple batch file question

Posted on 2007-04-03
10
229 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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

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…
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

762 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

19 Experts available now in Live!

Get 1:1 Help Now