Author
Topic: Collect images from a folder (Read 1964 times)

I have an excel file that has 8000 image names that I would like to have a script search a selected folder (with sub-folders) and copy the image from the list to a new folder. Any ideas if this is possible?

This is actually fairly simple, providing your excel doc is nicely made. (e.g. no sub headers, no gaps in the data).The following script should get you going and will work assuming your excel file is open, the image list is in column A and has no header.You will get problems if your destination folder is inside the search structure. You may have to do something if your images are in the list > once.As a bonus it will put the original path in column B if the image is found.

set theFolder to choose folder with prompt "Set the Search Location"set theSearchPath to POSIX path of theFolderset theDestination to choose folder with prompt "Set the Required Destination"set theDestination to POSIX path of theDestination

tell application "Microsoft Excel" set rownum to 1 repeat set theName to (value of cell 1 of row rownum) as string if theName = "" then exit repeat end if set thePath to "" set thePath to do shell script "find '" & theSearchPath & "' -name '" & theName & "'" if thePath = "" then set thePath to "not found" else do shell script "cp '" & thePath & "' '" & theDestination & "'" end if set value of cell 2 of row rownum to thePath set rownum to rownum + 1 end repeatend tell