Loading ...
Sorry, an error occurred while loading the content.

xcopy to create destination directory

Expand Messages
  • schelske.geo
    I am trying to copy c: bar to c: foo, and I need the bar directory created under the c: foo when the copy takes place. If c: bar contains 3 files, a.txt,
    Message 1 of 4 , Nov 8, 2006
    • 0 Attachment
      I am trying to copy c:\bar to c:\foo, and I need the bar directory
      created under the c:\foo when the copy takes place.

      If c:\bar contains 3 files, a.txt, b.txt, and c.txt the final result
      should be c:\foo\bar\a.txt, c:\foo\bar\b.txt, and c:\foo\bar\c.txt.

      I though xcopy /s would do it for me, but it just copies the files
      without creating the directory first. I tried the /i switch, but that
      didn't seem to help.

      What am I missing? Thanks.

      This is my actual command line

      xcopy c:\somedir \\pstst4s01\d$\d0129_backup /M/S/E/C/F/Y

      I want c:\somedir created in \\pstst4s01\d$\d0129_backup and then a
      copy of all files and subdirs?
    • foxidrive
      ... Try this: xcopy c: somedir pstst4s01 d$ d0129_backup somedir /M/S/E/C/F/Y -- Regards, Mic
      Message 2 of 4 , Nov 8, 2006
      • 0 Attachment
        On Wed, 08 Nov 2006 15:40:39 -0000, schelske.geo wrote:

        > I am trying to copy c:\bar to c:\foo, and I need the bar directory
        > created under the c:\foo when the copy takes place.
        >
        > If c:\bar contains 3 files, a.txt, b.txt, and c.txt the final result
        > should be c:\foo\bar\a.txt, c:\foo\bar\b.txt, and c:\foo\bar\c.txt.
        >
        > I though xcopy /s would do it for me, but it just copies the files
        > without creating the directory first. I tried the /i switch, but that
        > didn't seem to help.
        >
        > What am I missing? Thanks.
        >
        > This is my actual command line
        >
        > xcopy c:\somedir \\pstst4s01\d$\d0129_backup /M/S/E/C/F/Y
        >
        > I want c:\somedir created in \\pstst4s01\d$\d0129_backup and then a
        > copy of all files and subdirs?

        Try this:

        xcopy c:\somedir \\pstst4s01\d$\d0129_backup\somedir\ /M/S/E/C/F/Y

        --
        Regards,
        Mic
      • David Maunder
        ... Unfortunately that doesn t work under XP nor NT4. Yes, it prolly should, but doesn t. At least not on my XP or NT4 right here in front of me. Xcopy looks
        Message 3 of 4 , Nov 8, 2006
        • 0 Attachment
          > > I want c:\somedir created in \\pstst4s01\d$\d0129_backup and then a
          > > copy of all files and subdirs?
          >
          > Try this:
          >
          > xcopy c:\somedir \\pstst4s01\d$\d0129_backup\somedir\ /M/S/E/C/F/Y

          Unfortunately that doesn't work under XP nor NT4. Yes, it prolly should,
          but doesn't.
          At least not on my XP or NT4 right here in front of me.
          Xcopy looks damned buggy to me anyway.


          This is the only way that I can get it working corectly under XP:

          copymefilesover.bat
          MD %2\%1
          XCOPY %1 %2\%1 /S/E/C/F/Y

          Then do the following:

          Copymefilesover c:\somedir \\pstst4s01\d$\d0129_backup
          Which creates \\pstst4s01\d$\d0129_backup\somedir and copies the files.


          NT4 doesn't support the /y option.
        • Marc Peterson
          I can report that it works for me on XP SP2. I use xcopy all the time without issue. It s not often necessary, but I usually like to include the /H switch. I
          Message 4 of 4 , Nov 9, 2006
          • 0 Attachment
            I can report that it works for me on XP SP2. I use xcopy all the time
            without issue. It's not often necessary, but I usually like to include the
            /H switch.

            I notice that your first example includes the /M switch while the second
            example does not. Use of the /M switch will only copy files that have the
            archive attribute set.

            xcopy C:\somedir \\pstst4s01\d$\d0129_backup\somedir\ /e /c /h /y
            (The trailing slash on the destination precludes the need for /I)

            Marc

            > -----Original Message-----
            >
            > > > I want c:\somedir created in \\pstst4s01\d$\d0129_backup
            > and then a
            > > > copy of all files and subdirs?
            > >
            > > Try this:
            > >
            > > xcopy c:\somedir \\pstst4s01\d$\d0129_backup\somedir\ /M/S/E/C/F/Y
            >
            > Unfortunately that doesn't work under XP nor NT4. Yes, it
            > prolly should,
            > but doesn't.
            > At least not on my XP or NT4 right here in front of me.
            > Xcopy looks damned buggy to me anyway.
            >
            >
            > This is the only way that I can get it working corectly under XP:
            >
            > copymefilesover.bat
            > MD %2\%1
            > XCOPY %1 %2\%1 /S/E/C/F/Y
            >
            > Then do the following:
            >
            > Copymefilesover c:\somedir \\pstst4s01\d$\d0129_backup
            > Which creates \\pstst4s01\d$\d0129_backup\somedir and copies
            > the files.
            >
            >
            > NT4 doesn't support the /y option.
          Your message has been successfully submitted and would be delivered to recipients shortly.