REBOL [
    Title: "Add pre tag"
    Purpose: {Add an html pre tag as the first line of all
    dot-r scripts in a specified directory.}
]

;; [---------------------------------------------------------------------------]
;; [ This program was written after the transfer of the cobolrebol web site    ]
;; [ to a new host.  It appeared that their web server was serving up the      ]
;; [ dot-r scripts as just a string of characters without the line breaks      ]
;; [ that were present under the old host.  Therefore, as a simple fix,        ]
;; [ we added a pre tag as the first line of all scripts which seemed to       ]
;; [ cause the web server to serve them as we would like to see them.          ]
;; [---------------------------------------------------------------------------]

do %FilesOfType.r

directory: request-dir
if not directory [
    alert "No directory requested"
    quit
]
change-dir directory

FILE-LIST: FILES-OF-TYPE [%.r]

foreach FILENAME FILE-LIST [
    write FILENAME rejoin [
        "
"
        newline
        read FILENAME
    ]
    print [FILENAME " modified."]
]
print "Done."
halt