removing a pasted icon in a file

Hi, hope someone can help with this problem.

is there a way of removing the custom icon from a file, not the icmc image within the application but the custom icon you can add by pasting it in the get info window! the goal is to remove this pasted icon so that the only icon left is the original icmc icon.

any idea will help!

thank you!

Brian

Hi, I just coded the obvios solution:


tell application "Finder" to activate
tell application "System Events"
   keystroke "i" using command down
   keystroke tab
   keystroke delete using command down
end tell

I must say this does the job, but its not neat, is there a way of doing this without any additional windows? the user must not see anything at all.

Hope someone can help!

Brian

Hi, I found this code, but I can make it work … any idea in why will help!


on removeCustomFolderIcon(theFolderAlias)
   try
       do shell script "rm " & quoted form of ((POSIX path of theFolderAlias) & "Icon" & return)
       tell application "Finder" to update theFolderAlias
   end try
end removeCustomFolderIcon

thank you again!

Brian

That is a nice program but only works with folders! the icon I need to delete is the pasted icon in an Applescript app

thanks any way!

Brian :slight_smile:

this is my final solution:


set thesize to size of (info for x) as number
if thesize is greater than 1500000 then
	tell application "Finder" to activate
	tell application "System Events"
		try
			keystroke "i" using command down
			keystroke tab
			keystroke "x" using command down
			keystroke "w" using command down
		end try
	end tell
end if

it will only activate if someone changes the icon so its not that bad

Brian

With all respect, the solution StefanK posted to you in the thread " change the file icon of the current applet" is much better, as it doesn’t involve any ui scripting, which is a flaky business really.