I know it’s clunky, but this is a script I wrote years ago to figure out how long newspaper stories are going to be.
You pick a folder and it imports the stories one at a time does a character count, does some math and pastes into a text box the name of the story and the length in inches
But ever since I switched to OSX i get a message “storyLength is not defined”.
Well… to be truthful… the first time I ran it it told me all the stories were the same length, but I think that had something to do with that invisible file? at the top of every folder so i worked around that by importing files from the second file onward.
If I hard code in a path like “Macinstosh HD:Spam” (where spam is a word document) it works fine, so the problem has to be in the path? and the importing of the text?
Can anybody tell me what needs to be changed?
Thanks,
JA
choose folder “choose this week’s news folder”
set thePath to result as string
set numberOfStories to count of (list folder alias thePath)
set counter to 0
tell application “QuarkXPress™ 4.11”
activate
tell default document 1
set automatic text box to false
end tell
make document at beginning
tell page 1 of document 1
make text box at end with properties {bounds:{"8.5 cm", "5 cm", "10 cm", "10 cm"}}
end tell
tell page 1 of document 1
make text box at end with properties {bounds:{"2 cm", "2 cm", "27 cm", "10 cm"}}
make text box at end with properties {bounds:{"2 cm", "10 cm", "27 cm", "15 cm"}}
end tell
tell page 1 of document 1
repeat with i from 2 to numberOfStories
set storyFile to item i of (list folder alias thePath)
tell text box 1
try
set story 1 to alias (thePath & storyFile)
set characterCount to count of characters in story 1
set storyLength to (characterCount / 156.4)
end try
end tell
copy (storyFile as text) & return to after story 1 of text box 2
copy (storyLength as text) & return to after story 1 of text box 3
end repeat
delete text box 1
end tell
end tell