G'day from Oz
This script might interest some of you who add text to movies.
We have a partially deaf daughter, and I've taken to adding text to movies for her enjoyment. I use Jubler to check/edit the text files (.srt) and Submerge to burn the text into movies.
Unfortunately the text files often have 3 lines of text, and Submerge cuts the bottom line off. Fixing this in Jubler is tedious, so I wrote a script to take care of the problem.
Procedure.
1. Open the .srt file in TextEdit by dragging and dropping the file onto TextEdit (make sure there's only one TextEdit file open)
2. Run the script. It reduces any occurrence of 3 lines to 1 or 2 lines of text.
3 Save the TextEdit file. It will replace the .srt file.
Of interest, if you then only flatten the resultant video text, and save the video to iTunes, the text won't show. You have to actually burn the text onto the video, with the multiple export choices. iTunes can't handle flattened video super text any more.
If you use this script, and strike any problems, please let me know.
Regards
Santa
-- Jubler 2 liner
-- Copyright Brian Christmas 2012
-- Distribute freely.
property theContentsChange : {} global TempParagraph global CountThem
on run tell application "TextEdit" activate tell document 1 set theContentsChange to paragraphs as list end tell end tell set exitFlag to false set TempParagraph to 2 set CountThem to 0 repeat repeat repeat try set CheckNumber to (text item TempParagraph of theContentsChange) as number exit repeat on error set TempParagraph to TempParagraph + 1 end try if TempParagraph ≥ (count of theContentsChange) then set exitFlag to true exit repeat end if end repeat set ASCIIcount to 1 repeat if TempParagraph + ASCIIcount ≥ (count of theContentsChange) then set exitFlag to true exit repeat end if if TempParagraph ≥ (count of theContentsChange) then set exitFlag to true exit repeat end if if (ASCII number of text item (TempParagraph + ASCIIcount) of theContentsChange) = 13 then set TempParagraph to TempParagraph + ASCIIcount my reSet() exit repeat else set ASCIIcount to ASCIIcount + 1 end if end repeat set TempParagraph to TempParagraph + 1 if TempParagraph ≥ (count of theContentsChange) then set exitFlag to true exit repeat end if end repeat if exitFlag then exit repeat end repeat set the tempText to "" try repeat with EachLine in text items of theContentsChange set tempText to tempText & EachLine end repeat set the clipboard to tempText on error errmsg display dialog errmsg end try tell application "TextEdit" activate tell application "System Events" keystroke "a" using command down keystroke "v" using command down end tell
end tell say (CountThem & " lines altered") as text end run
on reSet() try set temp to (text item (TempParagraph - 3) of theContentsChange) as number -- Only one line return end try try set temp to (text item (TempParagraph - 4) of theContentsChange) as number -- Two lines return end try set templine to paragraph 1 of text item (TempParagraph - 3) of theContentsChange & " " & paragraph 1 of text item (TempParagraph - 2) of theContentsChange & " " & paragraph 1 of text item (TempParagraph - 1) of theContentsChange as text set CountThem to CountThem + 1 if (count of characters in templine) ≤ 50 then set theContentsChange to text items 1 through (TempParagraph - 4) of theContentsChange & templine & return & text items TempParagraph through (count of theContentsChange) of theContentsChange set TempParagraph to TempParagraph - 1 else set temp to (count of words of templine) set middletemp to temp div 2 as integer set templine2 to "" repeat with x from 1 to (temp - 1) set templine2 to templine2 & word x of templine if x = (middletemp + 1) then set templine2 to templine2 & return else set templine2 to templine2 & " " end if end repeat set templine2 to templine2 & word temp of templine set theContentsChange to text items 1 through (TempParagraph - 4) of theContentsChange & templine2 & return & text items TempParagraph through (count of theContentsChange) of theContentsChange set TempParagraph to TempParagraph - 2 end if end reSet
|