tell document 1 of application “Adobe InDesign CS5” to contents of every story
これで取り出せますが、順番がバラバラなので、一手間かけます。
実行すると同一フォルダに●●.indd.txtとして書き出されます。
tell document 1 of application “Adobe InDesign CS5”
set {a1, a7, a3, a2} to {parent page of parent text frames of character 1 of every story, geometric bounds of parent text frames of character 1 of every story, “”, parent story of parent text frames of character 1 of every story}
repeat with a4 from 1 to count a1
try
set {c1, c2} to {a7‘s item a4‘s item 1, a7‘s item a4‘s item 2}
set c1 to ((“000” & ((c1 div 1) as Unicode text)) as Unicode text)’s characters -3 thru end & (c1 mod 1 as Unicode text)’s characters 2 thru end as Unicode text
set c2 to ((“000” & ((c2 div 1) as Unicode text)) as Unicode text)’s characters -3 thru end & (c2 mod 1 as Unicode text)’s characters 2 thru end as Unicode text
set a3 to a3 & name of a1‘s item a4 & “:” & c1 & “:” & c2 & “:” & a4 & “\n”
end try
end repeat
tell current application to set a4 to do shell script “echo “ & quoted form of a3 & ” | sort -it: | sed -e ‘s/.*://’ | perl -pe ‘s/^$\n//'”
set {b1, b2} to {POSIX path of (file path as Unicode text), name}
set {a7, a5, a9} to {{}, b2 & “\r\r”, 0}
repeat with a8 in paragraphs of a4
set a7 to a7 & a8
end repeat
repeat with a6 in a7
try
set a11 to (“000” & a9)’s characters -3 thru end as Unicode text
set a12 to name of applied paragraph style of a2‘s item a6
set a5 to a5 & “##” & a11 & “_” & a12 & “\r” & contents of a2‘s item a6‘s item 1 & “\r\r”
set a9 to a9 + 1
end try
end repeat
set b6 to b1 & b2 & “.txt”
tell current application to do shell script “echo “ & quoted form of a5 & ” > “ & b6
end tell