Copy with A Command Line

  • Thread starter Thread starter Colinlam
  • Start date Start date
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
 
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\
 
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 /?


--
 
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?
 
This is because Sandgroper forgot to surround the source
folder e:\My Documents with double quotes. Have a look
at my own reply.
 
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.


--
 
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.
 
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.
 
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.
 
Please explain what exactly you mean with "from another
account". Are you running the command as a scheduled
job?
 
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.
 
If you wish to hide a task then scheduling it under a different
account with the Task Scheduler is the best solution.
 
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.
 
Back
Top