image
image

Go Back   macosx.com > Scripts > Apple Scripts

Reply
 
LinkBack Thread Tools
  #1  
Old December 30th, 2008, 04:35 AM
Registered User
 
Join Date: Dec 2008
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
David Hoffman is on a distinguished road
using a list to select files

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
Reply With Quote
  #2  
Old December 31st, 2008, 06:59 PM
Natobasso's Avatar
Tech-Bot 5000
 
Join Date: Jul 2002
Location: Auckland, New Zealand
Posts: 3,305
Thanks: 1
Thanked 20 Times in 20 Posts
Natobasso is on a distinguished road
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.
__________________
For more of my thoughts on tech and design issues, please see my blog: http://thesalon.blogspot.com
Reply With Quote
  #3  
Old January 2nd, 2009, 04:20 AM
Registered User
 
Join Date: Dec 2008
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
David Hoffman is on a distinguished road
Quote:
Originally Posted by Natobasso View Post
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.
Reply With Quote
  #4  
Old January 2nd, 2009, 04:28 AM
Natobasso's Avatar
Tech-Bot 5000
 
Join Date: Jul 2002
Location: Auckland, New Zealand
Posts: 3,305
Thanks: 1
Thanked 20 Times in 20 Posts
Natobasso is on a distinguished road
It does. Try it.
__________________
For more of my thoughts on tech and design issues, please see my blog: http://thesalon.blogspot.com
Reply With Quote
  #5  
Old January 2nd, 2009, 04:36 AM
Registered User
 
Join Date: Dec 2008
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
David Hoffman is on a distinguished road
Thumbs down nope

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.
Reply With Quote
  #6  
Old January 2nd, 2009, 04:39 AM
Natobasso's Avatar
Tech-Bot 5000
 
Join Date: Jul 2002
Location: Auckland, New Zealand
Posts: 3,305
Thanks: 1
Thanked 20 Times in 20 Posts
Natobasso is on a distinguished road
That's very noble of you.
__________________
For more of my thoughts on tech and design issues, please see my blog: http://thesalon.blogspot.com
Reply With Quote
  #7  
Old January 2nd, 2009, 02:07 PM
Mikuro's Avatar
Crotchety UI Nitpicker
 
Join Date: Mar 2005
Posts: 2,698
Thanks: 6
Thanked 55 Times in 50 Posts
Mikuro will become famous soon enough
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.
__________________
Mac mini — 1.25GHz G4, 1GB RAM — OS 10.5.8

Useful programs: Privoxy, Butler, ffmpegX, VLC, Perian, Tofu, Wcalc
Reply With Quote
  #8  
Old November 16th, 2009, 06:53 AM
Registered User
 
Join Date: Nov 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
joepies is on a distinguished road
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
Reply With Quote
Reply

Bookmarks

Tags
applescript, file handling, lists, select

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Forum Jump


All times are GMT -5. The time now is 06:04 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2
Copyright 2000-2010 DigitalCrowd, Inc.