Delete files named ("icon" & CR)?

Hi:

I occasionally have invisible files created in folders that are named (“icon” & CR). Yes, a carriage return, ascii 13, is part of the filename. Whenever such a file is encountered, it completely stops the copying process of the folder.

Does anyone know how to delete them via script, and how they get created in the first place?

Thanks for any insight,

guy o

Hi elgallorojo,

You can see my other recent post for why the icon file is there. This example shows how to delete it using the Finder:

set folder_path to (choose folder) as string
set icon_path to (folder_path & “Icon” & return)
try
set icon_ref to icon_path as alias
display dialog “Are you sure you want to delete the custom icon for the folder?”
tell application “Finder” to delete icon_ref
on error – the icon file doesn’t exist or user decided not to delete the existing one.
beep 2
– do something or nothing or return
end try

Editted: I haven’t tested it but think it should work.

gl,

Hi kel:

That worked great, thanks. I was using “file” instead of “alias” which always errored out.

In my opinion, this situation is ridiculous on the part of Apple, even more ridiculous than the inability to script the location of icons on the desktop… Every stinking day I have to rearrange them all the way I want them to be, not the OS. I hope Tiger will allow desktop icon scripting, especially by recording.

I wonder what people who don’t applescript do about this icon file situation…

Thanks again!

guy o