No File Icons

I am really new to applescript but managed to come up with the following droplet that converts a Word 2004 file to an rtf file (with appropriate extension). All works fine except that the new rtf file appears without an icon (but with its name underneatha blank square where the icon should be). Can anyone help? I have tried mending permissions but that doesn’t work. The script is as follows:

on open thefile
set text item delimiters to “/”
set thenewfile to POSIX path of thefile
set thenewfile to last text item of thenewfile
set lng to length of thenewfile
set x to lng - 3
set y to lng - 2
set z to lng - 1
set lastfour to character x of thenewfile & character y of thenewfile & character z of thenewfile & character lng of thenewfile
set x to x - 1
if lastfour is “.doc” then
set thenewfile to text from character 1 to x of thenewfile
end if
set thenewfile to thenewfile & “.rtf”
tell application “Microsoft Word”
open thefile
save as active document file name thenewfile file format format rtf
end tell
end open

Thanks for any help


I rewrote the code to fix some minor glitches:

on open fileList
	repeat with i in fileList
		set fileInfo to info for i
		set fileName to name of fileInfo
		set fileExtension to name extension of fileInfo
		if fileExtension is "doc" then ¬
			set newFileName to text 1 thru (offset of ".doc" in fileName) of fileName & "rtf"
		tell application "Microsoft Word"
			open i
			save as active document file name newFileName file format format rtf
			close active document
		end tell
	end repeat
end open

So, there is not the rtf-word icon in the saved file? What does it happen if you double-click the new rtf file?

Thanks for the rewrite; I learnt a lot from it!

What happens now is that the rtf file shows an icon of an iPodlike thing with DVD in the screen of the iPOD. When double-clicked it opens to WORD no problem. ANy further ideas on how to fix this, or what’s happening?

Thanks for any help.