Find images from list in Sku copy and paste to folder

I’ve found lots of scripts that do this but don’t have the best knowledge of how to do this but I have a list in CSV form that looks like this,

AB12NW01234AB2CD.PSD, AB12NW01234AB2CD, AltCode, Description
AB12NW01234AB2CE.PSD, AB12NW01234AB2CE, AltCodeE, Description

I need to use it to find the file (the first item of line) find the exact image, AB12NW01234AB2CD.PSD and then copy and paste it to another folder. to collect the required images.

Any one know how I could do this please?

Hi,

I’ve assumed a few things here but give the below script a try.

It will ask you to choose your csv file then a folder that contains the images that you want to copy. I won’t matter if the images are on the top level of the folder or nested in different folders the script should still find the images. Lastly it will ask you to choose the folder that you want to copy the images to. If the script doesn’t find a file it will display a dialog and if it finds multiple occurrences of the same file it will ask you to choose which one to copy.

set theCSV to read (choose file with prompt "Please choose csv files to process")
set source_folder to choose folder with prompt "Please choose folder containing Images"
set dest_folder to choose folder with prompt "Please choose folder to copy images to"

repeat with i from 1 to count of paragraphs of theCSV
	set thisPara to paragraph i of theCSV
	set Filename to my getFilename(thisPara)
	set thefiles to every paragraph of (do shell script "find " & quoted form of POSIX path of source_folder & " -name " & Filename & " -print")
	if thefiles is {} then
		display dialog "Cannot locate " & Filename
	else if (count of items of thefiles) > 1 then
		choose from list thefiles with prompt "which version of " & Filename & " would you like to move?"
	else
		set fileToCopy to item 1 of thefiles
		do shell script "cp " & quoted form of fileToCopy & space & quoted form of POSIX path of dest_folder
	end if
end repeat

on getFilename(thisPara)
	try
		set oldDels to AppleScript's text item delimiters
		set AppleScript's text item delimiters to ","
		set Filename to text item 1 of thisPara's text items
		set AppleScript's text item delimiters to oldDels
		return Filename
	on error theError
		set AppleScript's text item delimiters to oldDels
	end try
end getFilename

Hope this helps.

Thanks,
Nik