incopy to rtf

Im trying to convert incopy files to rtf using a folder action. I’m pretty clumsy with AS, so I’m butchering a similar script and I can’t get it working.

on adding folder items to this_folder after receiving these_items

repeat with i from 1 to number of items in these_items

    set this_item to item i of these_items

		tell application "Adobe InCopy CS3"

		open this_item
		
		export this_item as RTF in alias "/Users/steven/Desktop/Incopy Conversion/Converted"
		
		close this_item
		
		end tell

end repeat

end adding folder items to

Im getting an error on the export line. I just dont know how to code an export from InCopy. Can someone help me please?

Hi,

I don’t have InCopy, but I guess the export command expects a string path instead of an alias.
An alias causes always an error, if the file doesn’t exist
Try this, the folder Converted in folder InCopy Conversion on desktop must exist



on adding folder items to this_folder after receiving these_items
	set convertedFolder to ((path to desktop as text) & "Incopy Conversion:Converted:")
	repeat with i from 1 to number of items in these_items
		set this_item to item i of these_items
		set {name:Nm, name extension:Ex} to info for this_item
		if Ex is not missing value then set Nm to text 1 thru ((count Nm) - (count Ex) - 1) of Nm
		
		tell application "Adobe InCopy CS3"
			open this_item
			export document 1 as RTF in (convertedFolder & Nm & ".rtf")
			close document 1 saving no
		end tell
	end repeat
end adding folder items to

Thank you Stefan. Your script looks much nicer than mine, but I’m afraid both generates the same syntax error on the Export line.

Syntax error
Expected class name but found application constant or consideration.
And it highlights the RTF

I’m supposing InCopy wants something else here?

Look into InCopy’s dictionary to figure out the options

Thank you Stefan. I figured it out. You need the word format as a parameter. Much appreciated

Well I spoke too soon. It compiled, so I got excited. However it doesnt work…


on adding folder items to this_folder after receiving these_items
	set convertedFolder to ("Macintosh HD:Converted:")
	repeat with i from 1 to number of items in these_items
		set this_item to item i of these_items
		set {name:Nm, name extension:Ex} to info for this_item
		if Ex is not missing value then set Nm to text 1 thru ((count Nm) - (count Ex) - 1) of Nm
		
		tell application "Adobe InCopy CS3"
			open this_item
			export document 1 format RTF to (convertedFolder & Nm & ".rtf")
			close document 1 saving no
		end tell
	end repeat
end adding folder items to

It’s still getting stuck on the Export line. InCopy opens the first file and then sits there and does nothing. If I remove that line, the script will open and close the file, so it’s something wrong with the export.

Here’s the dictionary entry:

export‚v : Export the object to file
export document
format any : The export format, specified as an enumeration value or as an extension that appears in the Save as type or Format menu in the Export dialog. Can accept: tagged text/PDF type/RTF/text type/InCopy CS Document/InCopy Document or string.
to alias or text : The path to the export file.
[showing options boolean] : If true, displays the export options dialog.
[version comments text] : The comment for this version.
[force save boolean] : If true, forcibly saves a version.

The dictionary seems clear, and it looks correct. I’ve tried to replace the destination folder with straight text instead of the variable, but the same thing happens. Any ideas?