Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'GUI scripting not needed...' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
GUI scripting not needed...
Authored by: Krioni on Jun 17, '05 03:01:10PM
Remember, whenever you think GUI Scripting is the answer, check to see first if it is unnecessary. First, when I run your script, I get an error. Second, you can get the info about a selected Finder item without using GUI scripting. Try this:


on run
	tell application "Finder"
		set selectedItem to (item 1 of (get selection))
		set infoList to {}
		copy ("Displayed Name: " & displayed name of selectedItem) to end of infoList
		copy ("Kind: " & kind of selectedItem) to end of infoList
		copy ("Size: " & size of selectedItem & " (" & physical size of selectedItem & ")") to end of infoList
		copy ("Where: " & (selectedItem as alias) as string) to end of infoList
		copy ("Created: " & creation date of selectedItem) to end of infoList
		copy ("Modified: " & modification date of selectedItem) to end of infoList
		copy ("Name & Extension: " & name of selectedItem) to end of infoList
		copy ("Locked: " & locked of selectedItem) to end of infoList
		copy ("Comments: " & comment of selectedItem) to end of infoList
		copy ("Owner: " & owner of selectedItem) to end of infoList
		copy ("Group: " & group of selectedItem) to end of infoList		
	end tell
	set {od, AppleScript's text item delimiters} to {AppleScript's text item delimiters, return}
	set infoAsString to infoList as string
	set AppleScript's text item delimiters to od
	set the clipboard to infoAsString
	return infoAsString
end run

I don't know exactly which things you wanted from the Info window, but this is most of it. Also, you could write a script to clean up the scientific notation for the file size, but I'm not going to spend time on it now. :-) Notice also that if you have more than one item selected, this just gets the info for the first. You could re-write it to loop over multiple items.

[ Reply to This | # ]

Re: GUI scripting not needed...
Authored by: Uncle Asad on Jun 17, '05 05:24:40PM

Very cool...thanks!



[ Reply to This | # ]
GUI scripting not needed...
Authored by: ever on Jun 17, '05 07:03:56PM
That is a good script. This hint is a bit dated, because I was already able to find the stuff I wanted (like spotlight data, which doesn't appear in your script, or Finder's dictionary) by using other methods. It is, however, an interesting exercise in GUI scripting, and it might enlighten a few people who are trying to solve completely different problems.

[ Reply to This | # ]
GUI scripting not needed...
Authored by: adrianm on Jun 18, '05 03:12:28AM

Finder item properties don't have the "Where from", "colour depth", etc (basically, the mds info that Get Info shows).

So, short of extracting via GUI scripting or parsing an mdls call, you're pretty stuck.



[ Reply to This | # ]