View Full Version : Efficient way to convert 300 RTF files to TXT files to be place in MySQL database
jante99
06-18-2003, 10:50 AM
What would be an easy way to do this? Should I try to parse the RTF with PHP? I currently am just reading the TXT files with PHP and placing them in the database based on filename.
It seems like I could write an Applescript to bring the RTF content from Text Edit to BBEdit and save it as TXT but I am not sure how.
thuh Freak
06-18-2003, 03:32 PM
you can get the program 'unrtf' (available in fink). it converts rich text files to various formats (including text). unfortunately, the writer adds a header to all the output'd files, but you can chop that off (or hack the program to take the header off; it is OSS afterall).
jante99
06-18-2003, 04:49 PM
Originally posted by thuh Freak
you can get the program 'unrtf' (available in fink). it converts rich text files to various formats (including text). unfortunately, the writer adds a header to all the output'd files, but you can chop that off (or hack the program to take the header off; it is OSS afterall).
Unrtf doesn't seem to be available through fink. And I get an error when I try to compile the code from the site.
thuh Freak
06-18-2003, 04:57 PM
Originally posted by jante99
Unrtf doesn't seem to be available through fink. And I get an error when I try to compile the code from the site.
its on the unstable branch. you'll have to check their site to get directions to access the unstables, cuz i dont remeber the step-by-step. if you already have access, you may just need to update fink with 'sudo fink selfupdate-cvs'. i got errors trying to compile it myself too. if you edit the Makefile, putting 'CC=g++' (replacing what they had), and 'g++ ${OBJS} -o ${TARGET}' replacing what they had after '${TARGET}: ${OBJS}'. Then you should be able to compile with 'make'.
jante99
06-19-2003, 11:32 AM
I got the unrtf working with fink but now I wrote an Applescript to easily convert documents by dragging them onto the script:
on open names
string test = location of names
string test2 = "/sw/bin/untrf --text " + test
tell application "Terminal" to (do script test2)
quit
end open
The script compiles fine in Project Builder but I get error -2753 (variable test not defined) when I actually run the script.
vBulletin® v3.7.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.