I have hundreds of text clippings which have as their default name, the first paragraph of the clip. No problem until I try to use Carbon Copy Cloner to back them up to my Synology NAS. The file name is too long to be accepted, and the file fails to copy.
I could easily truncate their names in the finder, but then that breaks DevonThink, so I’d like to see a script that will do a simple truncate of the file name, say to 50 characters (or some rational amount).
Finding hundreds of these things by hand inside DT just isn’t realistic.
You can already affect this with the Script menu > Rename > Rename with RegEx using this source and destination pattern…
For those interested in some AppleScript, here is a teaching edition snippet…
property maxLength : 16
tell application id "DNtp"
repeat with thisRecord in (selection as list)
set currentName to (name of thisRecord)
if (count characters of currentName) > maxLength then
set truncatedName to (characters 1 thru maxLength of currentName) as string
set name of thisRecord to truncatedName
Aha! and -thank you- for your help and courtesy.
Hey there, is ist possible to detect long filenames with a smart rule or smart folder to fix them with this script? I´ve got the same Problem with hundreds of files causing errors on backup from mac to nas.
best regards, Thorsten
Sorry but no there is no criterion for the length of filenames.
And would you just want a hard truncation, e.g., only preserve the first 32 characters of the name?
yes, a hard truncation would be ok, can i use the script for > 30.000 files in my database at once?
I would not suggest doing that before you tested the behavior of the script you’re referring to.
You could use Tools > Batch Process on selected files, like so…
But again, test this on a few files first.
And yes, this could be used in a smart rule if this was needed on an ongoing basis.
it worked like a charm for all my files - thank you so much