Export text cue to a external file

116 views
Skip to first unread message

Samuel Thériault

unread,
Jun 10, 2023, 5:30:14 AM6/10/23
to QLab
Hi,

Does anybody have a script or part of a script to run through each text cue in a cue list and copy/paste in a .doc or .txt file?

Thank you.

Rich Walsh

unread,
Jun 10, 2023, 7:46:37 AM6/10/23
to ql...@googlegroups.com
Here are some bits:

tell application id "com.figure53.QLab.5"

tell front workspace

set listOfText to text of (cues whose q type is "Text")

set textOfText to my listToDelimitedText(listOfText, return)

my makeFileFromText((path to desktop) & "Text Cue Contents.txt" as text, textOfText)

end tell

end tell


on listToDelimitedText(theList, theDelimiter) -- [Shared subroutine]

set passedTIDs to AppleScript's text item delimiters

set AppleScript's text item delimiters to theDelimiter

set delimitedText to theList as text

set AppleScript's text item delimiters to passedTIDs

return delimitedText

end listToDelimitedText


on makeFileFromText(newFilePath, fileContents) -- [Shared subroutine]

copy (open for access newFilePath with write permission) to theOpenFile

set eof theOpenFile to 0 -- Clear it out first (just in case it already existed)

write fileContents to theOpenFile

close access theOpenFile

end makeFileFromText


Every Text Cue in the workspace.

Rich

Rich Walsh

unread,
Jun 10, 2023, 7:55:04 AM6/10/23
to ql...@googlegroups.com
Oh, but maybe you meant the other way round?

In which case you’d need to share a lot more about what you are pasting into the Text Cues: how to find it, how to associate it with the correct cue, how to format it, etc. Is it lines of the document, or a different document into each cue?

I’m sure there’s something Mic’s written to generate surtitles that would do that: https://qlab.app/cookbook/subtitles/.

Rich

Paul

unread,
Jun 13, 2023, 5:42:58 AM6/13/23
to QLab
I think you can do it like this...
tell application id "com.figure53.QLab.5" to tell front workspace

-- get all the text into an array
set myText to text of (every cue whose (q type is "Text"))

-- create the output file using the Workspace name
set AppleScript's text item delimiters to "."
set outfileName to (POSIX path of (path to desktop)) & (first text item of ((q number) as string)) & "_textcues.txt"
try
set outFile to open for access outfileName with write permission

set AppleScript's text item delimiters to linefeed
write (myText as text) to outFile starting at eof

display dialog (myText as text) with title "text written to file " & outfileName
on error errorMessage
display notification "error opening file " & errorMessage
end try
end tell

Reply all
Reply to author
Forward
0 new messages