Jump to content

Need A Text " Search And Replace " Cmd Line Utility For Thai Text


JetsetBkk

Recommended Posts

Anyone know of a Windows XP Command Line utility (for use in batch/command files) that can search a directory for files containing specific Thai text and replace it with English text.

I use the Sunbird calendar program which can import calendar files, but it generates an error if the file contains Thai text, so I need to replace the Thai text with English text.

Any ideas?

Link to comment
Share on other sites


If you're familiar with Unix command line utilities like sed, grep and srtrings you can download windows binary ports from here.

http://www.highend3d.com/downloads/tools/os_utils/76.html

You would then have to do a regular expression find and replace.

If I can think of anything less hardcore, I'll get back to you. Maybe someone else has an easier way of doing this?

Link to comment
Share on other sites

Another alternative, assuming its not in binary format, is opening it in Notepad and saving it in ANSII character format. The Thai characters won't be supported in the save operation. If you try re-opening it, the Thai characters should be replaced with a ? or something. You can then just do a search and replace for a single character rather than every letter in the Thai alphabet

Link to comment
Share on other sites

Thanks for the links MS. Those utils are interesting, but not exactly what I need to run in a command file.

What I'd like is something like this:

searchreplace.exe -i"inputfile" -s"searchstring" -r"replacestring" [-o"outputfile"] (if no outputfile, modify inputfile)

It's also important that the input filename can include wildcards, e.g. *.ics

Another alternative, assuming its not in binary format, is opening it in Notepad and saving it in ANSII character format. The Thai characters won't be supported in the save operation. If you try re-opening it, the Thai characters should be replaced with a ? or something. You can then just do a search and replace for a single character rather than every letter in the Thai alphabet

Hmm, interesting approach. It does work, but I had to change the language "to match the language version of the non-Unicode programs" in Control Panel's "Regional and Language Options".

This language is normally set to Thai on my PC, so saving the file as ANSII didn't change the Thai characters, but after resetting the "non-Unicode language" to English, the ANSII version file had question marks as you said it would.

It's a bit of a kluge and not easy to do using command files, so I hope you can think of something less "hardcore". :o

Link to comment
Share on other sites

Not a command line utility... and I've not used it in this way, [& not using a multi-language system to check quickly, sorry] but you might want to look for BkreplaceEm. Provides very powerful multi-file, string replacement functions, and though I'm guessing, I'd anticipate it would work with system level languages for input given its development history.

HTH

Regards

Link to comment
Share on other sites

Not a command line utility... and I've not used it in this way, [& not using a multi-language system to check quickly, sorry] but you might want to look for BkreplaceEm. Provides very powerful multi-file, string replacement functions, and though I'm guessing, I'd anticipate it would work with system level languages for input given its development history.

HTH

Regards

Thank you very much A_T! That's done the job nicely. I had to put the Thai text string(s) in another text file for the program to input as cut and paste didn't work, but the great thing is you can have multiple Thai strings to search for and replace them with different English texts. And all these operations can be done in one go on all files in a folder - perfect for what I need to do.

Thanks again. :o

Link to comment
Share on other sites

My pleasure, very glad to be able to help.

Be warned though it can be horribly powerful with expressions, I still make sure I set it to backup, ... now where's the embarrassed whistling whilst getting my coat emoticon.

Regards

Yes, I've made sure that the folder it works on is at the bottom of a directory tree on my data disk, and only modifies .ics files (calendar files). Wouldn't want any nasty mishaps... :o

Link to comment
Share on other sites

This is a link to free Unix tools for Windows (Win32) , grep the Unix command line find and replace utility is inlcluded.

http://unxutils.sourceforge.net/

However nothing beats opening terminal on the Mac or any Linux box and using grep command line :o

Hope the Windows app helps people looking for a windows grep.

grep [options] PATTERN [FILE...]

grep [options] [-e PATTERN | -f FILE] [FILE...]

grep searches the named input FILEs (or standard input if no files are

named, or the file name - is given) for lines containing a match to the

given PATTERN. By default, grep prints the matching lines.

In addition, three variant programs egrep, fgrep and rgrep are avail-

able. egrep is the same as grep -E. fgrep is the same as grep -F.

rgrep is the same as grep -r.

Link to comment
Share on other sites

I know this is a little late but I have seen this in Bangkok Post....

http://www.bangkokpost.com/tech/techscoop/...ace-text-easily

Hope it works.

Hi sensei - yes, it works perfectly and I got it to produce results identical to "BKreplaceEm". It looks and feels a better written utility than BKreplaceEm, but it has some deficiencies:

1. It doesn't allow the saving of the search folder, so you have to browse through your folder tree to get to the right one

2. It allows the saving of "Search and Replace" strings, but only one at a time. So you have to run the program more than once if you have more than one "search and replace" pair to change.

3. It doesn't produce a log file, but does display the results and also allows testing before doing the replacing.

So although BKreplaceEm feels older - some windows can't be dragged bigger: you have to use scroll bars, and the web site is pretty poor - it is more user friendly. I particularly like the fact that you only have to run it once to change many different "Search and Replace" strings.

I might send some suggestions to the grepWin author if I can find a contact link, as I prefer the look and feel of it and it appears to be regularly updated.

Link to comment
Share on other sites

Anyone know of a Windows XP Command Line utility (for use in batch/command files) that can search a directory for files containing specific Thai text and replace it with English text.

I use the Sunbird calendar program which can import calendar files, but it generates an error if the file contains Thai text, so I need to replace the Thai text with English text.

Any ideas?

BUY A MAC

Link to comment
Share on other sites

Anyone know of a Windows XP Command Line utility (for use in batch/command files) that can search a directory for files containing specific Thai text and replace it with English text.

I use the Sunbird calendar program which can import calendar files, but it generates an error if the file contains Thai text, so I need to replace the Thai text with English text.

Any ideas?

BUY A MAC

It's not raining.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.








×
×
  • Create New...
""