Hi,
Because this is not implemented in DT, I’m trying to understand how to rename files using Custom MetaData.
Seems we can use something like those things :
“AppleScript”. I absolutely don’t know what it is and how to record or what to do
There is a *rename using RegEx" menu. Unable to use it. What is RegEx?
Seems we can use Ajax ? (hu?)
I simply want to use the “identifiant” to rename my file
But I’m not a software engineer and to not have time to learn but to use my data
When processing inbox items, I use an Applescript to rename the file;
see sample below for set name of theNote to theTitle
I use additional code to derive theTitle; it can reference custom metadata
tell application id "DNtp"
set theNote to move record theNote to theFilingGroup
set name of theNote to theTitle
end tell
Replace mdextags in line set thisRecord_CustomMetaData_Value to mdextags of thisRecord_CustomMetaData with md plus your Custom Meta Data identifier
Save script to DEVONthink’s script menu folder ~/Library/Application Scripts/com.devon-technologies.think3/Menu/
Usage
Select some records in the item list (or one of the other views).
Run script via DEVONthink’s script menu.
-- Rename records based on Custom Meta Data
tell application id "DNtp"
try
set theRecords to selected records
if theRecords = {} then error "Please select some records"
repeat with thisRecord in theRecords
set thisRecord_CustomMetaData to custom meta data of thisRecord
try
set thisRecord_CustomMetaData_Value to mdextags of thisRecord_CustomMetaData -- replace mdextags with "md" plus your identifier
set name of thisRecord to thisRecord_CustomMetaData_Value
end try
end repeat
on error error_message number error_number
if the error_number is not -128 then display alert "DEVONthink" message error_message as warning
return
end try
end tell
Thank you for your answer.
I’ve put a test file in Inbox and run the script but nothing happens.
When I launch this script from AppleScript an error occurs
What is it this script supposed to do?
It opens a box or something and then I manually enter the name?
About the error : do I have something to do with “the note” variable?
I’ve edited the script this way but nothing happen (I don’t know how to embed this script in this message) :
-- Rename records based on Custom Meta Data
tell application id "DNtp"
try
set theRecords to selected records
if theRecords = {} then error "Please select some records"
repeat with thisRecord in theRecords
set thisRecord_CustomMetaData to custom meta data of thisRecord
try
set thisRecord_CustomMetaData_Value to md_company of thisRecord_CustomMetaData -- replace mdextags with "md" plus your identifier
set name of thisRecord to thisRecord_CustomMetaData_Value
end try
end repeat
on error error_message number error_number
if the error_number is not -128 then display alert "DEVONthink" message error_message as warning
return
end try
end tell
What I want is to rename the selected file with those 3 identifier :
company
date (need to be yyyymmdd)
objet
As a result my files will be organized by emitter / date and objet.
(in next lige I will learn to use IA to detect date and other stuff)
Yes, it can’t run. The code contains several variables which are not declared in this code.
I guess @DTLow posted it to show how a record theoretically could be renamed via AppleScript.
However, I think it’s not a good idea to post code that won’t run without modifications without making potential users aware of the fact that it won’t run. That’s especially important in case of users who have no scripting/programming background (yet).
I posted a script that does what you asked for in your first post.
Now you changed your goal. May I ask why? Did you initially forget to mention what your desired output names should look like? Please don’t take this as offensive, I’m really just curious.
It’s always a good idea to
post an example of the desired output (e.g. Apple - 2022-02-27 - MacBook Pro)
As per @pete31, this was not a complete script - just sample code to illustrate renaming a file
I did mention “additional code”; the post is edited to say “sample”
I’m sorry this wasn’t clearer
It’s not the first time that someone copies code without thought or understanding,
and reports “it doesn’t work”
There’s also the problem with clearly defined requirements
About the error : do I have something to do with “the note” variable?
As per the error message, you have to define variable theNote
There are various options using additional code; I like the *selected records" in the above script
In fact I did not change but was not able to explain what I want to do at first.
I thought I was far easier and while thinking about it, I discovered date format is not the same.
I thought I was simply able to catch the data and use it as a name. But it seems far far far much complex.
Just need to manage file not become a software engineer
My desire output is exactly this " emitter - yyyymmdd - object"
You are right, I have exactly no background at all. For me Applescript is absolutely not understandable.
It seems it will take month to understand what to do with Applescript.
Hello
Thank for your time.
Your script does not work either. Nothing happen.
In fact, I don’t understand what do I have to adapt.
I’ve change
set thisRecord_CustomMetaData_Value to mdextags of thisRecord_CustomMetaData -- replace mdextags with "md" plus your identifier
set thisRecord_CustomMetaData_Value to md_company of thisRecord_CustomMetaData -- replace mdextags with "md" plus your identifier
But nothing happen.
I’me really afraid I can’t conclude this project easily,
I can’t understand. I’ve replaced mdextags
That’s crazy, I can’t see from where comes the problem. Do I become silly?
You write “replace mdextags with “md” plus your identifier”
Do I need to write md or “md”?