Hi,
I was wondering if anyone could help me find a solution to perform a word count on a document (.docx) then put the output in the title of that document as a suffix ?
Hope this is clear enough
Hi,
I was wondering if anyone could help me find a solution to perform a word count on a document (.docx) then put the output in the title of that document as a suffix ?
Hope this is clear enough
You could use the “word count” property:
tell application id "DNtp"
set theSel to the selection
repeat with theRecord in theSel
set theWordCount to word count of theRecord
set name of theRecord to name of theRecord & "-" & (theWordCount as string)
end repeat
end tell
This is my approach, as sometimes a file has an extension in the name and sometimes it doesn’t…
tell application id "DNtp"
repeat with thisRecord in (selection as list)
set {fname, wc} to {name, word count} of thisRecord
set name of thisRecord to (do shell script "reg=\".*\\.[0-9a-zA-Z]{2,4}$\";nm=" & quoted form of fname & "; [[ $nm =~ $reg ]] && echo $nm | sed -E 's_(^.*)(\\.[0-9A-Za-z]{2,4})_\\1 - " & wc & " words\\2_' || echo $nm - " & wc & " words")
end repeat
end tell
But no, it won’t make “words” singular for a “1” or “0”.
Hi,
I’m really sorry that i couldn’t post a reply earlier. Thank you for the solution it’s going to save me a lot of time and effort.
It’s really frustrating to see that the solution holds in a few lines.
Thanks a lot to cgrunenberg and to BLUEFROG