Solved

Moving large quanities of files from inside folders to one master file

Posted on 2013-01-18
7
399 Views
Last Modified: 2013-01-21
Experts: I have hundreds of PDF documents inside multiple folders (one case=PDF file of about 100 pages per case); I'd like to copy all of the pdfs (about 1000 cases that inside each folder (1000 folders) into one master folder of just the pdf docs. So the structure is:
1 file case # 12345 in folder #1 contains 1 pdf; next folder is pdf #12346, next folder is pdf #123457. I need to extract every pdf inside each folder (again, 1000 folders) and move them all into one singular folder for batch operations on all of the pdf files (1000 files). Any suggestion on the easiest way to extract them all from each folder and put all of the PDFs into one master folder together? The pdfs should be sequential, i.e. not in folders when completed, in one folder. Any suggestions?? Thanks all.

Much appreciated.
0
Comment
Question by:satzm
  • 3
  • 2
  • 2
7 Comments
 
LVL 25

Expert Comment

by:Tony Giangreco
ID: 38795240
Use a simple batch file like this

md newpdfs
xcopy c:\Casepdfs\*.pdf  c:\newpdfs /s

It will go through the entire structure of your folders and copy all PDF's found into a new folder.
0
 
LVL 38

Expert Comment

by:BillDL
ID: 38795951
Hi satzm

TG-TIS has suggested the easiest method to achieve this, but the  /S  switch copies folders and sub-folders to the destination, which is not what you want.  You want all the PDF files in one destination folder minus the original source directory structure.

Do you know whether there are two or more PDF files with the same file names in different source folders?

That will make a difference, because otherwise the first one copied will be overwritten by subsequent ones copied unless the batch file is written to take account of this.
0
 
LVL 25

Expert Comment

by:Tony Giangreco
ID: 38796370
I have found a replacement utility that does perform the copy process, searches through all folders in the search path and writes all files to one destination folder with no sub-folders. It also has the option of added the original folder name it was copied from which is handy if you have duplicate file names in different folders.

Here is information on the utility and how to dowbnload it.

Search and collect files into just one directory.

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

 
In many cases, collecting certain files into a directory may save a
  lot of time.  For example, if you gather all Microsoft Word document
  (.DOC) files from the entire volume into just one subdirectory,
  browsing them and locating a particular file become much easier.
  That is what XXCOPY's /SX, /SG and their variations are for.

  The traditional way to do this is (don't type beyond the comment //... ),

     XCOPY  C:\*.doc  D:\mydocs\   /S       // using Microsoft's XCOPY
     XXCOPY C:\*.doc  D:\mydocs\   /S       // the same here with XXCOPY

       The /S switch makes the copy operation to recursively
       go inside subdirectories and copy all matching files.
       If subdirectories are not present in the destination,
       they will be created as needed.

       ----------------------------------------------------------
         Note that the destination directory was deliberately
         chosen in a different drive in the examples above.
         Watch out if the destination is in the same volume...

           XCOPY  C:\*.doc  C:\mydocs\   /S       // a FATAL error
           XXCOPY C:\*.doc  C:\mydocs\   /S /CCY

         This is a classic case of the cyclic copy situation which
         Microsoft's XCOPY cannot handle.  Using /CCY, our XXCOPY
         allows you to specify the destination in the same volume.
         See XXTB #07 for detail.
       ----------------------------------------------------------

     Although the files you wanted are all copied into the destination,
     the destination directory will inevitably have many subdirectories
     which makes your next step still very time-consuming.

XXCOPY provides better solutions.

  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
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:satzm
ID: 38798507
BillDi: The files (folders) definitively do not have the same names.  Each file is a separate case with a separate court case #.

TG-TIS, I am sorry, I am not an administrator on the network, so do not have authority (security settings) to add new programs to the network. I need to work this within a windows environment without adding additional programs (notwithstanding that program looks perfect :( but I can't use that answer).
0
 
LVL 38

Accepted Solution

by:
BillDL earned 500 total points
ID: 38799930
Thanks satzm

In that case a simple copy command should work for you.  It's so easy it's criminal ;-)
I am at work in a non-IT environment and cannot test this though.

1. Create a new destination folder where you want all the PDF files, ie. your Master Folder.
2. Copy the text in the code snippet below, paste into Windows Notepad, and then change the path shown as "C:\Path_To\PDFs" to the top line folder containing all the sub-folders with your PDF files.
3. File menu > Save As > Navigate to the new "master folder" you created, and name the file "CopyPdfs.cmd"
(the file name isn't important, but be sure to name it with the  .CMD  file extension, because this is your batch script).
4. Double-Click on the "CopyPdfs.cmd" file.

The command walks down through all the sub-folders starting at the top level folder specified, and copies all PDF files it finds into the same folder as the batch file, which will be your new master folder.

@echo off
for /r "C:\Path_To\PDFs" %%A in (*.pdf) do (
    echo Copying "%%~nxA"
    copy /-Y /V "%%A"
)
pause

Open in new window

The /V switch means "Verify that files are written correctly", which will slow the process down but is probably a good idea to leave.  The /-Y switch forces it to prompt if an overwrite would occur.
0
 

Author Comment

by:satzm
ID: 38803868
BillDL: Thanks big time; that's the ticket! Much appreciated; this is why I subscribe to EE, you guys are great. Thanks again.
0
 
LVL 38

Expert Comment

by:BillDL
ID: 38803990
You're welcome satzm, but go easy on the compliments or we (me) will get big-headed ;-)
Glad you have a working solution to the problem.

What might be a good idea before you go deleting all the folders and sub-folders containing all the court case PDFs, is to verify that the files all copied.  Probably the easiest way would be to just select all the PDFs in your new master folder (Edit menu > Select All) and see how many PDF files it says are there (exclude the batch file that is probably still in that folder from the count).  Then run a DIR command on the top level folder where the PDFs were copied from and see how many PDF files it tells you are in those folders on the final lines.  Example:

dir /a-d /on /s "C:\Path_To\PDFs\*.pdf"

Bill
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This article is an update and follow-up of my previous article:   Storage 101: common concepts in the IT enterprise storage This time, I expand on more frequently used storage concepts.
When you start your Windows 10 PC and got an "Operating system not found" error or just saw  "Auto repair for startup". After a while, you have entered a loop for Auto repair which does not fix anything and you will be in a  panic as all your work w…
In this video, we discuss why the need for additional vertical screen space has become more important in recent years, namely, due to the transition in the marketplace of 4x3 computer screens to 16x9 and 16x10 screens (so-called widescreen format). …
This video teaches viewers how to encrypt an external drive that requires a password to read and edit the drive. All tasks are done in Disk Utility. Plug in the external drive you wish to encrypt: Make sure all previous data on the drive has been …

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now