using a list to select files

David Hoffman

Registered
I have a folder with a few thousand jpg & tif images and a list of about 800 image filenames that looks like

bags of cocaine.tif,Poll Tax panorama.tif,lump of cocaine.tif,smoking crack in spoon.tif,fly agaric,meals on wheels, Hackney,Farm Chemicals 1.jpg,

As you'll see, some have extensions, some don't. Some names in the list have no corresponding file in the folder of images. many of the images in the folder are not named in the list.

Some of the images in the folder are named with the extension but the name in the list has no extension.

There are no images in the folder that exist as both tif and also as jpg versions.

I need to use the list to mark the images that are listed. The best thing would be to give them a finder label but selecting them or moving them to a subfolder would be fine.

I've spent the best part of a day failing to grasp enough Applescript to do this - can anyone show me the way?

TIA!

David Hoffman
 
List them by kind, first. That will weed out your jpg and tif dot extension named files. Then you just have to deal with the unmarked ones. Do you have "Show All Dot Extensions" turned on in Finder preferences? You might find the rest of the .jpg and .tif file names might appear on their own.
 
List them by kind, first. That will weed out your jpg and tif dot extension named files. Then you just have to deal with the unmarked ones. Do you have "Show All Dot Extensions" turned on in Finder preferences? You might find the rest of the .jpg and .tif file names might appear on their own.
That wasn't what I asked about. Listing by kind doesn't relate to my question. I need to move specific files of different kinds by using their names from a list to find them in a separate folder.

I now have an Applescript that does that so the problem is fixed.
 
Either you've not read my question or you've not understood it.

I don't want to waste other peoples' time and bandwidth so will not respond further.
 
AppleScript is appropriate for this task. Something like this should work:
Code:
set name_list to "file1
file2.jpg
file3.tif" --just paste the whole text file into these quotes
set AppleScript's text item delimiters to ASCII character 10
if the number of text items of name_list < 2 then set AppleScript's text item delimiters to ASCII character 13 --depending on the alignment of the stars, the text above might be formatted differently but look exactly the same.
set name_list to every text item of name_list

tell application "Finder"
	set the_folder to the folder of window 1 --the currently active folder in the Finder
	repeat with n in name_list
		try
			set (the label index of every item of the_folder whose name begins with n) to 1 --label matches orange
		end try
	end repeat
end tell

Caveats:

1. The folder with the images must be open and frontmost in the Finder before running this script.
2. If the file has no extension in the list then it will work, but if it has a wrong extension it will fail. So if you have a file named x.jpg, it will match against "x" but not against "x.tif".
3. If the list contains any quote marks, you won't be able to paste it into the script as I wrote it. Extra formatting will be necessary.

Hope this helps.
 
David, Mikuro
I have a similar challenge, selecting files from a list. The applescript code that was posted here seems to be very, very slow.

David, would you mind sharing your code?

Thanks,

Joris
 
It is easy to follow and carry out. Thanks for your posting. It is very helpful for me. Yaaaah...;)

This is what i am looking for so far. It is very helpful for me. Yaaahhh
__________________
 
Last edited by a moderator:
Back
Top