I have a lot of files imported from an email List. They have sequential numbered names: 038526, 038527 and so forth. The subject of the email is always the first line in each file.
What I would like to do is to automate renaming each file with
.
So “038526”, “038527” would be renamed:
First Line of First File
First Line of Second File
I have no idea if this can be done, and if it can, how.
Note: There are approximately 40,000 files (40,000 individual emails).
hi, this script should get you started. It works with simple rich text and plain text files in my database.
-- Set name to first line
tell application id "com.devon-technologies.thinkpro2"
try
set counter to 0
set theSelection to the selection
if theSelection is {} then error "Please select some contents."
repeat with theRecord in theSelection
set counter to counter + 1
try
set name of theRecord to (counter as string) & ". " & (paragraph 1 of rich text of theRecord) as text
end try
end repeat
on error error_message number error_number
if the error_number is not -128 then display alert "DEVONthink Pro" message error_message as warning
end try
end tell
Finally! Got this batch rename RTF files working again. Hallelujah!
I removed the automatic numbering because I want the title to begin with the first letter.
Just one more detail and my world will be sunshine:
Can I edit this script so that it ignores quotation marks, numerals, and other characters so the title ends up starting with the first letter?
I would very much like a script to rename in this way. It is standard on many markdown note editors, and after importing some notes to DT I have a lot of notes with names like: 0FF20711-C015-44B5-9C00-F3ABC148F19B. I can’t spend the time to rename them all one-by-one. I don’t mind if it truncates overly long names, but having some kind of readable text would be nice!