Efficient way to convert 300 RTF files to TXT files to be place in MySQL database

Posted:
in Genius Bar edited January 2014
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.

Comments

  • Reply 1 of 4
    thuh freakthuh freak Posts: 2,664member
    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).
  • Reply 2 of 4
    jante99jante99 Posts: 539member
    Quote:

    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.
  • Reply 3 of 4
    thuh freakthuh freak Posts: 2,664member
    Quote:

    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'.
  • Reply 4 of 4
    jante99jante99 Posts: 539member
    I got the unrtf working with fink but now I wrote an Applescript to easily convert documents by dragging them onto the script:

    Code:


    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.
Sign In or Register to comment.