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


Click here to return to the 'Easily copy all versions and sizes of a file's icon' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Easily copy all versions and sizes of a file's icon
Authored by: coolsoldier on Aug 08, '06 10:26:50AM

Two things:

1. This doesn't work for documents that preview is capable of opening.

2. I don't see any way to save the result as an .icns file.

Otherwise, it seems to work.



[ Reply to This | # ]
Easily copy all versions and sizes of a file's icon
Authored by: Lankhmart on Aug 08, '06 11:42:19AM
You can copy to the clipboard just as the hint says, then run this script to save as an icns file:

try
	set icns to the clipboard as «class icns»
on error err number -1700
	display alert "Please select an item in the Finder and copy to the clipboard before running this script." as warning buttons {"OK"} default button 1
	return
end try

set desk to (path to desktop)
set icns_file to choose file name with prompt "Save icon:" default name "untitled.icns" default location desk

set file_ref to open for access icns_file with write permission
try
	set eof file_ref to 0
	write icns to file_ref
	close access file_ref
on error err number num
	close access file_ref
	display dialog ("Error writing file: " & err & " (" & num & ")") buttons {"OK"} default button 1
	return
end try
tell application "Finder"
	set creator type of icns_file to "prvw"
	set file type of icns_file to "icns"
end tell


[ Reply to This | # ]
Easily copy all versions and sizes of a file's icon
Authored by: chyna4xena on Aug 15, '06 05:03:39AM

Wow, that is great, thanks!

I am running 10.3, and I had to remove the 'as warning' section from the 'display alert' line before it would compile.

Now it seems to work (generates icns files with three icons that open in Preview), except that a 'stack overflow' error is generated by the Finder commands that attempt to change the creator and file type.



[ Reply to This | # ]