Google Answers Logo
View Question
 
Q: Copying files in Windows ( Answered 5 out of 5 stars,   2 Comments )
Question  
Subject: Copying files in Windows
Category: Computers > Operating Systems
Asked by: respree-ga
List Price: $2.00
Posted: 31 May 2003 09:27 PDT
Expires: 30 Jun 2003 09:27 PDT
Question ID: 211143
Can anyone tell me how to copy files from one drive to another (i.e. D
to C)?

The source lets say its a CD on the D drive has subdirectories in it.

I wish to copy all the files including all files within all
subdirectories to the C: drive, however I *do not* wish to maintain
the original subdirectory structure of the source.  I just want all
the copied files to be placed into one (destination) directory.

I've tried: xcopy d:*.jpg c:\dev /s (dev being the destination
directory)

...but it copied all the subdirectories along with it. Can't seem to
figure out the right switch.  Can anyone assist?  Thanks.
Answer  
Subject: Re: Copying files in Windows
Answered By: answerguru-ga on 31 May 2003 10:17 PDT
Rated:5 out of 5 stars
 
Hi respree-ga,

Thanks for the interesting question; I've always wondered if this was
possible in windows but this gave me a reason to dig further than
normal :)

It turns out that xcopy (a copy utility included with Windows) is
actually incapable of copying files to a destination without the
subdirectories. This triggered a search for a utility that would be
able to achieve such a feat, and I ended up coming across this
program:

XCOPY - a Versatile File Management Utility---Boldly Extended Xcopy
http://www.xxcopy.com/

The following XXCopy Technical Bulletin exactly describes that
situation you (and no doubt countless others) have experienced:

" XXCOPY has a better way to deal with the situation that avoids
making
  subdirectories in the destination.  Of course, it is inevitable that
  many files share the same filename.  So, XXCOPY synthesizes new
  names when duplicate files are to be copied into the destination.

     XXCOPY C:\*.doc  D:\mydocs\   /SX
     XXCOPY C:\*.doc  D:\mydocs\   /SG

  Our original directory-flattening functions (/SX, /SL and /SR)
combine
  the source directory path (only the distinguishing part) with the
  source filename to form a long filename which is always unique
  (and you can tell where the files are from).

      /SL     Flattens subdirectories, add-name-Left
      /SX     Flattens subdirectories, add-name-Middle
      /SR     Flattens subdirectories, add-name-Right

  By popular demand by XXCOPY users, we re-engineered the new
file-gathering
  functions /SG and its variations which retain the original filename.

      /SG     same as /SGN (newest one and sorted by newness)
      /SGN    sorted, newest file first
      /SGO    sorted, oldest file first
      /SGF    unsorted, first come first served

      /SGNO   picks the newest file
      /SGOO   picks the oldest file
      /SGFO   picks the first file encountered

  That's a total of nine flavors to choose from!  Our favorite is /SGN
  which got the honor of being equivalent to its shorter version, /SG.


The /SX (/SL or /SR) switch flattens a directory.

  To understand how these schemes work, it is easiest to actually
  run the command and take a look at the destination directory.
  Let us start with the directory-flattening functions.

    XXCOPY C:\*.doc  D:\mydocs\   /SX     // puts path in the middle

       The result would be

       D:\mydocs\MYFILE`My Documents`word`.DOC
       D:\mydocs\MYFILE`Junk`Vote2000`gore`.DOC
       D:\mydocs\MYFILE`Junk`Vote2000`bush`.DOC
       D:\mydocs\MYFILE`Junk`Vote1996`dole`.DOC
           ...

     The four MYFILE.DOC files are collected from four directories.
     In this case, the backslash (directory name delimiter) is
converted
     into a legal character which is infrequently used in filenames
     (default = back-apostrophe (`)).  (See below to select the
directory
     name delimiter character other than the default character).

     The /SL and /SR variations respectively place the pathname part
     either at the left or at the right of the filename.  We like the
     /SX version the best among the three variations because the new
     filename starts like the original and the ending also remains
     the same so the Windows knows which application to associate
     the file when you double click the file icon.


The /SG switch gathers files into a directory.

  All the file-gathering functions (/SG and its variations) work
  identically if there is only one file for a given filename.
  The switches with O (not zero, but Oh) at the end keep only one file
  Newest, Oldest, or the First one found) for a given filename.

  On the other hand, other /SG functions have to gather all files
  with the same filename into one directory.  Therefore, we need to
  synthesize the filenames for the duplicates.  XXCOPY simply adds
  a "middle name" to the filename.  For example,


     XXCOPY C:\*.doc  D:\mydocs\   /SG     // sort, newest file first

       The result would be

       D:\mydocs\MYFILE.DOC                // the newest file
       D:\mydocs\MYFILE.0001.DOC           // 2nd newest
       D:\mydocs\MYFILE.0002.DOC           // 3rd newest
       D:\mydocs\MYFILE.0003.DOC           // 4th newest
          ...


  These functions are fun to play with.
  For example, just see how many .JPG (image) files are on your system

      XXCOPY C:\*.jpg  C:\temp\   /SG /CCY

      You may be surprised how much space is tied up with them.
      This particular example may become your favorite tool to
      snoop your children's computer for questionable pictures!!!


Reversal of flattening = rebuilding the tree.

  With regard to the difference between /SX and /SG, for a casual and
  temporary usage, the /SG switch seems easier for most people.  The
  most important difference of the two approaches is that the /SX (and
  also /SL and /SR) switch synthesizes the new filename without losing
  the origin of the file.  As a matter of fact, XXCOPY provides the
  following three switches which allow you to rebuild the original
  directory structure from the destination (flattened) directory.

      /SLR   Rebuild the original directory from directory made by /SL
      /SXR   Rebuild the original directory from directory made by /SX
      /SRR   Rebuild the original directory from directory made by /SR

      Note that these switch must match the way the flattened
directory
      was made.  For example if you flatten a directory using /SL, you
      must use /SLR and so on.  Also, the directory name delimiter
      character must be consistent between the flattening and the
      rebuilding steps.


      Examples:

           XXCOPY C:\word\*.doc  D:\mydocs\   /SX        // flattens
           XXCOPY D:\mydocs\     C:\word2\    /SXR       // rebuilds

         The ultimate destination directory (C:\word2\) would contain
         the same files and subdirectories as in the above two steps
         when you run the following command which copies the files
         to the destination directly.

           XXCOPY C:\word\*.doc  C:\word2\    /S
"

http://www.xxcopy.com/xxcopy16.htm

You can download this freeware program from:
http://www.xxcopy.com/download/xxcopy.zip

The stipulations associated with this freeware can be found here:
http://www.xxcopy.com/index.html#tag_03

If you need to use this program for commercial use, XXCopy Pro
Licenses are also available:
http://www.xxcopy.com/index.html#tag_05

Well I can tell you I actually brought this into my own machine and
played around with it for a bit - I love it! Hopefully it will bring
you the same level of joy (or relief, whichever you prefer).

Search Strategy (Google):

windows xcopy tutorial (actually found in the sponsored links)

If you have any problems understanding the information above please
feel free to post a clarification and I will ensure a prompt response.

Cheers!

answerguru-ga
respree-ga rated this answer:5 out of 5 stars and gave an additional tip of: $3.00
Awesome app.  Thanks so much.

Comments  
Subject: Re: Copying files in Windows
From: answerguru-ga on 31 May 2003 11:44 PDT
 
Hi respree-ga,

Thanks for your great rating, kind words, and generosity. They have
not gone unnoticed :)

answerguru-ga
Subject: Re: Copying files in Windows
From: respree-ga on 31 May 2003 13:13 PDT
 
My pleasure.  And thank you.  I was actually expecting a two character
answer, like "/x" or something like that.  Didn't expect that much
work was involved, but I thank you for your persistence in finding me
the answer to my question. To be honest, I was wondering why the
question was locked for so long, but know I know why.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy