Annette Fowler

Searching for (and then copying) a large number of files in Windows 7

Est. Reading Time: 2 minutes

Recently a client provided me with over 10,000 product images, from which I was supposed to find the 800 or so files relevant for the current project. Quick calculations told me that searching the zip file manually, one file at a time, from the spreadsheet provided would take many more hours than I had, so I needed to automate the process.  Here are the steps I took:

  1. Unzip the file of all images provided and make sure that all images are all in one folder and not in sub-folders.
  2. Get a list of all images provided in the folder using a DOS command (I blogged about this earlier here):  dir /a-d /b > filelist.txt
  3. Copy this list from the text file to Excel and sort the list by file name
  4. Open the spreadsheet provided of the images that should be copied to the website.  Create a vlookup command to search the list of file names copied in #2 (to confirm all images were found in the folder):  =VLOOKUP(A1,’Sheet1′!$A$1:$A$10000,1,FALSE).  This will put an “N/A” in the cell for any image that is not found.  The client was contacted about these images, because they were not provided.
  5. In the next column, create a dos command that will copy the image from the current folder to a new one (leaving the remaining images in the current folder and just the ones I need in a new folder):  =”Copy “&CHAR(34)&A1&CHAR(34)&” “&”New /Y”.  The “char” puts quotes around the image names, because many of my images had spaces in them (thanks to this site for assistance with this step).
  6. Copy the entire column of copy commands into Notepad.  Save the new notepad file as “batch.bat” in the same folder as the current images.
  7. Create a new folder called “New” in the folder were the images reside currently
  8. Go to a dos command and type “batch.bat”.  The program will begin running.  Mine took about 1/2 hour, but I’m sure it would depend on network speed, computer processing, number of files, etc.  Regardless, it is not instantaneous.
  9. Viola!  A “New” folder with only the images I needed!

Hope this was helpful to you!  Do you have a faster way to automate this process?  Please comment below!