I would like to have a column with the character count. Now with the new custom meta data it could be done with an AppleScript. I tried to modify the Count Characters script, but the “add custom meta data” command seems not to work. Maybe I misunderstood how to use the command. Here’s the script:
-- Count Characters.
-- Created by Christian Grunenberg on Mon Jun 07 2004.
-- Copyright (c) 2004-2014. All rights reserved.
tell application id "DNtp"
try
set this_selection to the selection
if this_selection is {} then error "Please select some contents."
show progress indicator "Counting characters" steps -1
set this_characters to my countCharacters(this_selection)
hide progress indicator
display alert "DEVONthink Pro" message "Zeichen gezählt und in Metadaten ergänzt"
on error error_message number error_number
hide progress indicator
if the error_number is not -128 then display alert "DEVONthink Pro" message error_message as warning
end try
end tell
on countCharacters(these_childs)
local this_child, this_count
tell application id "DNtp"
set this_count to 0
repeat with this_child in these_childs
add custom meta data (character count of this_child) for "zeichen" to this_child
end repeat
end tell
end countCharacters
-- Character Count to Custom Data
-- Created by Jim Neumann / BLUEFROG on Fri Apr 26 2019.
-- Copyright (c) 2019 BLUEFROG / DEVONtechnologies, LLC. All rights reserved.
-- This assumes a custom metadata attribute with an identifier of charcount and a data type of Integer (as you obviously can't have fractional words).
-- And yes, this will log 0 words, unless you code for it otherwise.
tell application id "DNtp"
repeat with thisRecord in (selection as list)
tell thisRecord
set chars to (character count)
add custom meta data chars for "charcount" to it
end tell
end repeat
end tell
Technically speaking, @cgrunenberg would have to answer that. But it’s likely due to your attempt is essentially running a sub-command inside a command.
This may work in some apps or instances, but I wouldn’t bet on it. Using a variable is also just a safer bet.
tell application id "DNtp"
repeat with thisRecord in (selection as list)
set countCharactersInName to (count characters in (name of thisRecord as string))
end repeat
end tell