Jump to content


Xcopy question


4 replies to this topic

#1 OFFLINE   n8chavez

    Advanced Member

  • Members
  • PipPipPip
  • 81 posts

Posted 17 March 2007 - 07:02 PM

I'm adding a backup option to my context menu. I want to make it so that whatever directory I'm in I can right-click on a file or folder and have it backed up to a certain location. This is the command I have so far:

Quote

xcopy /e /s /h /k /y %1 D:\Backups\
My question is: How do I maintain the same directory structure? If I want to backup c:\docs how can I make sure that they are copied to d:\Backups\docs? As it is right now the "docs" subdirectory does not get copied. Of course, this is just an example.

Any ideas?

#2 OFFLINE   Andavari

    Captain Spectacular

  • Moderators
  • 13,327 posts
  • Gender:Male
  • Location:Shadow Moses

Posted 17 March 2007 - 07:25 PM

At the command prompt type in: xcopy /h
this will list all the available parameters it can use.

Basically you're missing one of the following:

Quote

/S Copies directories and subdirectories except empty ones.

Quote

/E Copies directories and subdirectories, including empty ones.
Same as /S /E.

Edit: Oops just noticed you're already using /e /s.
Complexity of incoherent design.

#3 OFFLINE   n8chavez

    Advanced Member

  • Members
  • PipPipPip
  • 81 posts

Posted 17 March 2007 - 08:13 PM

View PostAndavari, on Mar 17 2007, 12:25 PM, said:

At the command prompt type in: xcopy /h
this will list all the available parameters it can use.

Basically you're missing one of the following:
Edit: Oops just noticed you're already using /e /s.

Yeah t's a bit tricky. This command will copy *.* from a folder I right-click on including subdirectories but it will not create the main directory; the "docs folder does not get created upon backup, just everything inside the folder.

#4 OFFLINE   Andavari

    Captain Spectacular

  • Moderators
  • 13,327 posts
  • Gender:Male
  • Location:Shadow Moses

Posted 18 March 2007 - 01:00 AM

Have you tried your parameter with quotes around %1 and your directory, so that it would become:
xcopy /e /s /h /k /y "%1" "D:\Backups\"

Complexity of incoherent design.

#5 OFFLINE   n8chavez

    Advanced Member

  • Members
  • PipPipPip
  • 81 posts

Posted 18 March 2007 - 03:51 AM

View PostAndavari, on Mar 17 2007, 06:00 PM, said:

Have you tried your parameter with quotes around %1 and your directory, so that it would become:
xcopy /e /s /h /k /y "%1" "D:\Backups\"
No luck. It didn't work.