on run
main()
end run
on main()
set DateString to current date
set DateString to date string of DateString
set AppleScript's text item delimiters to ","
set DateString to DateString's text items 2 thru 3 as text
set AppleScript's text item delimiters to ""
set index1Flag to false
tell application "Tex-Edit Plus"
if not (window 1 exists) then
beep
return
else
tell window 1
if (name of window 1) contains "index1.html" then set index1Flag to true
-- Initialize lists
if not index1Flag then
set searchList to {"pictures/", "thumbs/", "JPG"}
set replaceList to {"/photo/pictures/", "/photo/thumbs/", "jpg"}
else
set searchList to {"pictures/", "thumbs/", "]PG"}
set replaceList to {"/photo/pictures1/", "/photo/thumbs1/", "jpg"}
end if
tell window 1
repeat with x from 1 to the number of items in replaceList
replace replacing with item x in replaceList looking for item x in searchList with cases matching and whole words matching
end repeat
-- html replacement string
replace looking for "<body>" replacing with "<body><center><h1 class=title>" & DateString & "</h1></center>"
replace looking for "<h1 class=title></h1>" replacing with ""
replace looking for "<td width=\"576\" colspan=\"3\" />" replacing with "<td width=\"576\" colspan=\"3\">"
end tell
end tell
ignoring application responses
do shell script "say -v Alex " & "The replacing has ben completed. You should save the new file now."
-- say "The replacing has ben compleeted. You should save the new file now."
end ignoring
display dialog "Ok to save?" buttons {"OK", "No"} default button 1
if text of button returned of result = "No" then
return
else
tell application "Tex-Edit Plus" to activate
select window 1
tell application "Tex-Edit Plus" to close window 1 saving yes
end if
end if
end tell
return
end main
TIA,