Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2013-01-18
7
Medium Priority
?
434 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

 

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 2000 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

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

While working, an annoying popup showing below will come and we cannot cancel or close it form the screen. The error message will come again and again.
When we purchase storage, we typically are advertised storage of 500GB, 1TB, 2TB and so on. However, when you actually install it into your computer, your 500GB HDD will actually show up as 465GB. Why? It has to do with the way people and computers…
The viewer will learn how to successfully download and install the SARDU utility on Windows 7, without downloading adware.
The Task Scheduler is a powerful tool that is built into Windows. It allows you to schedule tasks (actions) on a recurring basis, such as hourly, daily, weekly, monthly, at log on, at startup, on idle, etc. This video Micro Tutorial is a brief intro…

715 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