Copy with A Command Line

C

Colinlam

Hi, I am hopeless with command lines and most of those that I use I've got
from this forum, so thanks.

I want to copy "My Documents" from one location too another as a backup. I
thought if I had a command line I could put it in the "Run" box of Scheduled
Tasks and make a daily backup.

The details of my set are:
The My Documents(Colin's Documents) folder is at the root of Drive
E:\

The folder I wish to copy it too is called "Backups" at the root of
Drive F:\

Will I need a switch to force it to copy over an existing folder?

Thanks
 
P

Pegasus \(MVP\)

Colinlam said:
Hi, I am hopeless with command lines and most of those that I use I've got
from this forum, so thanks.

I want to copy "My Documents" from one location too another as a backup. I
thought if I had a command line I could put it in the "Run" box of Scheduled
Tasks and make a daily backup.

The details of my set are:
The My Documents(Colin's Documents) folder is at the root of Drive
E:\

The folder I wish to copy it too is called "Backups" at the root of
Drive F:\

Will I need a switch to force it to copy over an existing folder?

Thanks

Try something like this:

xcopy /s /y /c "e:\My Documents(Colin's Documents)" F:\Backups\
 
S

Sandgroper

Colinlam said:
Hi, I am hopeless with command lines and most of those that I use I've got
from this forum, so thanks.

I want to copy "My Documents" from one location too another as a backup. I
thought if I had a command line I could put it in the "Run" box of
Scheduled Tasks and make a daily backup.

The details of my set are:
The My Documents(Colin's Documents) folder is at the root of Drive
E:\

The folder I wish to copy it too is called "Backups" at the root of
Drive F:\

Will I need a switch to force it to copy over an existing folder?

Try this command , this will copy all files and sub directories :
xcopy e:\My Documents /a /y f:\backups

For a complete list of switches , at a command prompt type
xcopy /?


--
 
C

Colinlam

Hi, Thanks for your help. To try out your suggestions I ran them both from a
command prompt and they both came back with an "Invalid number of
parameters" error.

I'm sure we are close but any further suggestions?
 
P

Pegasus \(MVP\)

This is because Sandgroper forgot to surround the source
folder e:\My Documents with double quotes. Have a look
at my own reply.
 
S

Sandgroper

Colinlam said:
Hi, Thanks for your help. To try out your suggestions I ran them both from
a command prompt and they both came back with an "Invalid number of
parameters" error.

I'm sure we are close but any further suggestions?

Oh crap , I put the switches in the wrong place.
:(

The format of the command is :
xcopy </switch1/switch2......> <source files> [1 character space]
<destination files>

xcopy /s/y e:\My Documents f:\Backups
or
xcopy /s /y "e:\My Documents(Colin's Documents)" f:\Backups

It is best to create f:\Backups directory first before you can use this
command otherwise you will be prompted to create a directory.


--
 
C

Colinlam

Hi, thanks to you both for your help.

I ran

xcopy /s /y "e:\Colin's Documents" f:\Backups

and it copied each folder in Colin's Documents to Backups so I created a
folder in Backups called Colin's Documents Backup and ran

xcopy /s /y "e:\Colin's Documents" f:\Backups\Colin's Documents Backup

and it came back with the "Invalid number of parameters" error.

Any ideas why?

Thanks again to you both.
 
P

Pegasus \(MVP\)

Colinlam said:
Hi, thanks to you both for your help.

I ran

xcopy /s /y "e:\Colin's Documents" f:\Backups

and it copied each folder in Colin's Documents to Backups so I created a
folder in Backups called Colin's Documents Backup and ran

xcopy /s /y "e:\Colin's Documents" f:\Backups\Colin's Documents Backup

and it came back with the "Invalid number of parameters" error.

Any ideas why?

How about adding some double quotes around your destination
folder? They are ALWAYS required when names have embedded
spaces, and can also be added to names without embedded
spaces.
 
C

Colinlam

Hi, job done works really well.

I am running it from another account so I don't see the window, could I do
this with a switch?

Thanks again I don't know what I would do without this forum.
 
P

Pegasus \(MVP\)

Please explain what exactly you mean with "from another
account". Are you running the command as a scheduled
job?
 
C

Colinlam

Hi, yes I'm running it as a scheduled task and so that I don't get the
window flash up I run it from another Admin account.
 
P

Pegasus \(MVP\)

If you wish to hide a task then scheduling it under a different
account with the Task Scheduler is the best solution.
 
C

Colinlam

Ok thanks for all your time

Pegasus (MVP) said:
If you wish to hide a task then scheduling it under a different
account with the Task Scheduler is the best solution.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top