Get contents of a clipping

Is it possible to get the contents of a clipping? I’ve looked around the forums and found people saying that you can’t SET the contents but I’m just trying to pull whats in a clipping out. I’ve tried it a few different ways:

get contents of clipping “clipping”
read contents of clipping “clipping”
get text of clipping “clipping”
read text of clipping “clipping”

I usually get an error that it can’t make every text of clipping into a file. Any ideas would be appreciated.

~Joe

You can use Satimage osax (free) or Extra Suites (reasonably priced for all of the features that it provides) to do both. Here’s the code to get the text from a clipping file…

-- via Satimage
set clip_path to "path:to:clipping file"
set clip_text to load resource 256 type "TEXT" from alias clip_path

-- via Extra Suites
set clip_path to "path:to:clipping file"
tell application "Extra Suites" to ¬
	set clip_text to ES read resource alias clip_path type "TEXT" id 256

– Rob

Thanks, I’ll try those. What part of Ohio are you in, I’m from Mansfield.

I’m in the Lima area. :slight_smile:

Cool, I think we played Lima in football in high school. :slight_smile: Hey I have a silly question for you. Is there a list of character codes for things like a carriage return and tab? I’m trying to get a script to look for a quotation mark and it’s not working so I’m thinking I have to use a code. Thanks.

Sorry, I finally found the FAQ section of this site and figured it out. :slight_smile:

Alright I got pretty far with that scripting add-on. I’m stuck with something else and I’m just missing something. I’m still pretty new to applescript and am just doing it on a project by project basis. Right now I’m trying to take addresses from a clipping and bring them into Address Book and make each clipping it’s own group. I can get it to make entries for all the addresses and extract the group name but I can’t get it to add them to the group. Here’s the script (sorry if it’s convoluted, I’m piecing together a lot of stuff).


set clip_path to (choose file)

set clip_text to load resource 256 type "TEXT" from clip_path
set start_ to 1
set Partial to text start_ thru (length of clip_text) of clip_text
set end_ to offset of return in clip_text
set groupName to text 1 thru (end_ - 1) of clip_text
set the_text to clip_text

set address_list to my extract_addresses(the_text)

tell application "Address Book"
	activate
	set everyContact to address_list
	repeat with eachContact in everyContact
		try
			set newCard to make new person
			set properties of newCard to {first name:eachContact}
			
			tell newCard
				make new email at beginning of emails with properties {label:"work", value:eachContact}
				save addressbook
			end tell
		end try
	end repeat
end tell

tell application "Address Book"
	set newGroup to make new group with properties {name:groupName}
	repeat with eachContact in everyContact
		add eachContact to newGroup
		
	end repeat
end tell


on extract_addresses(the_text)
	set {the_text, address_list} to {words of the_text, {}}
	repeat with i from 2 to (count of the_text)
		try
			if item i of the_text = "@" then
				set temp_address to ((item (i - 1) of the_text) & (item i of the_text) & (item (i + 1) of the_text)) as string
				if temp_address is not in address_list then
					if (my verify_address(temp_address)) then set end of address_list to temp_address
				end if
			end if
		end try
	end repeat
	return address_list
end extract_addresses

on verify_address(temp_address)
	set address_parts to (text items of temp_address)
	if (count of address_parts) < 2 then return false
	set AppleScript's text item delimiters to "."
	set address_parts to text items of temp_address
	set AppleScript's text item delimiters to ""
	if (count of address_parts) < 2 or (count of item -1 of address_parts) > 4 then return false
	return true
end verify_address

Does this work?

repeat with eachContact in everyContact
	add person eachContact to group groupName
end repeat

– Rob

I had tried that and for some reason no.

If I do:
repeat with eachContact in everyContact
add person “name@site.com” to newGroup
end repeat

where “name@site.com” is one of the addresses that’s in the list it adds that one to the group. So why wouldn’t it work with the whole list that way? when it try it with add person eachContact it gives me an NSReceiverEvaluationScriptError: 4. I got the value of eachContact and it’s a list setup like this:

item 35 of {“name@site.com”, “name@site.com”, etc}

Does this address the issue?

repeat with eachContact in everyContact
	add person (contents of eachContact) to newGroup
end repeat

– Rob

YES! :slight_smile: I was trying all kinds of stuff but not that. Thanks so much!