Hello there, im pretty new in applescript and im looking for a script to
convert a single text file i a dir on my desktop to a html file, all the content
in my textfile should work like “url” in the html output.
Currently im using this script to make the txt file… maby this can be recoded
to send the html output
set the_folder to ("OS X:Users:mkh:Desktop:logs")
set the_log to ("WWW:test:myfile.txt:")
set file_list to list folder the_folder without invisibles
tell (a reference to AppleScript's text item delimiters)
set {old_atid, contents} to {contents, return}
set {file_list, contents} to {"" & file_list, old_atid}
end tell
my write_to_file(the_log, file_list, false)
beep
on write_to_file(the_file, the_data, with_appending)
set the_file to the_file as file specification
try
open for access the_file with write permission
if with_appending = false then set eof of the_file to 0
write the_data to the_file starting at eof as (class of the_data)
close access the_file
return true
on error the_error
try
close access the_file
end try
return false
end try
end write_to_file
set myHeader to "<html><head><title>Converted with AppleScript!</title></head>
"
set endHTML to "
</html>"
set myFile to (choose file)
set myContents to (do shell script "cat " & quoted form of POSIX path of myFile)
set myHTML to myHeader & myContents & endHTML
set myFolder to (do shell script "dirname " & quoted form of POSIX path of myFile)
do shell script "cd " & quoted form of myFolder
do shell script "echo " & quoted form of myHTML & " > " & quoted form of myFolder & "/index.html"
i don’t entirely understand your question, but this is really basic. you may want to edit the HTML, and you may need to parse words to add HTML tags. this should get you started.