set current_date to current date
month of (current_date)
set currentmonth to result as number
if currentmonth < "10" then
set currentmonth to "0" & currentmonth as string
end if
day of (current_date)
set currentday to result
if currentday < "10" then
set currentday to "0" & currentday as string
end if
year of (current_date)
set currentyear to result
set currentdate to currentmonth & "-" & currentday & "-" & currentyear as string
set current_time to time of (current_date) as string
path to desktop
set path_to_desktop to result as string
set daily_readings to {path_to_desktop & "daily_readings_" & currentdate & "_" & current_time & ".txt"} as string
tell application "BBEdit"
activate
replace "\"" using "'" searching in text 1 of text window 1 options {search mode:literal, starting at top:true, wrap around:false, backwards:false, case sensitive:false, match words:false, extend selection:false}
replace "^" using "say \"" searching in text 1 of text window 1 options {search mode:grep, starting at top:true, wrap around:false, backwards:false, case sensitive:false, match words:false, extend selection:false}
replace "$" using "\"" searching in text 1 of text window 1 options {search mode:grep, starting at top:true, wrap around:false, backwards:false, case sensitive:false, match words:false, extend selection:false}
replace "^" using "delay 4\\r" searching in text 1 of text window 1 options {search mode:grep, starting at top:true, wrap around:false, backwards:false, case sensitive:false, match words:false, extend selection:false}
save text window 1 to file daily_readings
close text window 1
end tell
tell application "Script Editor"
open alias daily_readings
end tell