convert text from UTF to "Cyrillic Windows" encoding?

How to convert a Textwrangler files from UTF to “Cyrillic Windows” encoding?
All files are in one folder and although the main text is in in I receive several red inverted question marks.
I tried this:


tell application "TextWrangler"
	activate
	set properties of front document to {line breaks:Unix, encoding:"Cyrillic (Windows)"}
end tell

or

tell application "TextWrangler"
	activate
	set properties of front document to {line breaks:Unix, encoding:"Cyrillic Windows"}
end tell

and different versions but I always get this error

TextWrangler got an error: An unexpected error occurred while processing an Apple Event (MacOS Error code: -10000)

Hi,

The following code works for me:


tell application "TextWrangler"
	tell document 1
		set line breaks to Unix
		set encoding to "Cyrillic (Windows)"
	end tell
end tell

Best regards from Berlin,

Martin

Thanks Martin

Martin when I tried to choose a folder and create a loop I get this error

Can’t set «class LinB» of {«class TxtD» 1 of application “TextWrangler”, «class TxtD»

How can I fix this? I have hundred files …

Thanks

Hi danwan,

Could you show us the complete code? That would help a lot.

Best regards,

Martin

Thanks Martin I use this code is a pearl code
and it seems to work no

set inputfolder to (choose folder)
set theFiles to list folder inputfolder without invisibles

repeat with x from 1 to count of theFiles
	set thefile to item x of theFiles
	set inputfile to quoted form of (POSIX path of inputfolder & thefile)
	--set line breaks to Unix
	do shell script "perl -pi -e 's/\\r/\\n/g' " & inputfile
	--set encoding to "Cyrillic (Windows)"
	do shell script "textutil -convert txt -encoding windows-1251 -output " & inputfile & " " & inputfile
end repeat