Anyway of doing this?

Soldato
Joined
26 Jun 2011
Posts
4,902
Have an excel sheets with something like 1000 product codes.

Have a folder of something like 5000 images.

What would be a quick way to pull those 1000 image codes out of this big folder without doing it manually :eek:
 
Probably not the most efficient way of doing this, but only way I can think of. I've also not got excel so there's a fair chance this won't actually work.

-Open command prompt and run "dir [pathToFolder] > C:\files.csv"
-Open in notepad and run a find/replace for "<DIR>" and ","
-Open file in excel

From there should be able to copy the content into the existing spreadsheet and run some kind of validation thing to sort everything, but I don't use excel much so no idea how to do this last bit.
 
Hmmm the issue is having something that would read a particular list of file names and then search, find and copy the files into a new folder.
 
Ah right, thought you wanted a way to match product/image codes in excel, although now I think about it that doesn't make any sense lol.
 
Load your 1000 names into an array, then run a foreach fnmatch against the files directory, if true move/copy the file to a new dir and continue.
 
Can be either

Here's a simple way using batch commands then.

Create a file, go.bat in the same folder as your images and in it add:

Code:
@echo off
REM Filename to search in
SET filename=codes.txt
REM Image extension
SET extension=.jpg
REM output folder
SET outputFolder=out

ECHO Creating output folder
MKDIR %outputFolder%
ECHO. 

FOR /F "tokens=*" %%i IN (%filename%) DO (
	ECHO Copying file %%i%extension% to %outputFolder%
	COPY %%i%extension% %outputFolder%\%%i%extension%
	
	REM Test - makes a blank file for each code to test copying with with
	REM type nul >>%%i%extension%
)

In the same folder make a file called codes.txt, which contains your product codes. E.g.:
Code:
abc100
abc101
abc102
abc103
abc104
abc105
abc106
abc107
abc108
abc109
abc110
abc111
abc112
abc113
abc114

The above batch will loop over the contents of codes.txt and look for an image called <code>.jpg, e.g., abc107.jpg and will attempt to copy it to the out folder.

Double-click or run go.bat from the command line and hope it works :p.
 
Hmmm the issue is having something that would read a particular list of file names and then search, find and copy the files into a new folder.

The batch file idea (above) is definitely viable. Make sure to save your spreadsheet as MS-DOS TXT.

The easiest way is VBA (visual basic for applications) which you can develop within Excel (Alt and F11 when your spreadsheet is open).
 
Back
Top Bottom