"Collecting" files from a list...

I’ve been all over these forums looking for this sort of thing and am amazed that there is nothing like it out there. I’m hoping someone here can help me create it, or create it for me should I prove too new to applescript!

I work in a business where I’m constantly needing to “collect” a bunch of files for clients. Typically I need to gather a few hundred web-sized or small print sized files out of several thousands we keep on a large drive. The lists of files to copy (or collect for the client) are always unique and drawn from a database.

Is there a way to create an applescript that will read from a list of file names and then copy these files from a specified directory? We have several different spec’d file types and get requests in the form of these lists for each kind. I don’t need to have the script know the difference in file collection types, I could just run it on the proper directory, with the proper list and would hope to end up with a folder/directory of the files copies and ready for burning or uploading. I’d then trash the duplicate file, leaving the source files in place.

I hope this is as easy as I think it could be. I have tinkered with applescript and even automator and have had problems getting the ‘iterative’ part of using a list/loop to work. I think it is purely my inexperience.

Can anyone help? Thank you so much in advance.

Hi bentricks,

I would suggest the code below to get you started. It retrieves file names from an internal list and checks if they exist in a source folder. If so, it duplicates the found files to a destination folder. Please note, that I created this sample code on Mac OS X and cannot currently check, if it also runs under Mac OS 9. But there is no special X voodoo used, so it might run just fine.

The code is very simple and does not search sub folders for the given file names.


set filenames to {"File_1.jpg", "File_2.png", "File_3.pdf"}
set sourcefolderpath to "Macintosh HD:Desktop Folder:Source Files:"
set destfolderpath to "Macintosh HD:Desktop Folder:Destination:"

repeat with filename in filenames
	set sourcefilepath to (sourcefolderpath & filename) as Unicode text
	try
		set sourcefilealias to sourcefilepath as alias
		tell application "Finder"
			duplicate sourcefilealias to (destfolderpath as alias)
		end tell
	end try
end repeat

Now back to work. Lunch time is over…

Wow! Thanks.

I took your basic script there and plugged in a few little options and the thing works like a charm. I can’t express enough how much this will help!

I am always amazed by the collective ability of this forum. It is awesome to be able to come here and learn so much great stuff.