Change filename into certain format

Hi Devonthink users,

Hope you guys are having a fantastic day so far.
I want to set a similar smart rule like this automator

,
but I get stuck at the execution part because I dont have knowledge to terminology.

I want to set the format as

[years] _ [type of documents] _ [name of subjects]

For example:
2024_Syllabus_Statistics
2025_Lecture regression_Statistics
2025_assignment 01_Statistics

because [type of documents] is hard to change automatically, I think leaving it blank would be fine.

How can i make this kind of renaming possible?

Many thanks

Instead of a smart rule, I use an AppleScript to assist with processing records in my Inbox.
It does renaming, tags, etc
Script code can present a list of “type of documents” for selection

We hope you’re having a good day as well :slight_smile:

  • Are you anticipating multiple rules?
    • If not, what criteria would determine the document type and subject name?

Also, if this isn’t something that happens habitually, I would look at Tools > Batch Processing instead.

thank you, however I have 0 knowledge on AppleScript so i guess I need to find different solutions :joy: :joy:

The need for scripting depends on the parameters of the operation.

In case you’re not aware, in the “Change Name” field in Batch Process… or a Smart Rule, you don’t manually input text (besides static text). You right click and navigate to “Insert Placeholder” – there’s a long list to choose from.

If you have [type of documents] or [name of subjects] in custom or regular metadata, that could be one way to go about it.

You can read about all the placeholders in the Help/manual under Appendix > Placeholders.

1 Like

not really a criteria, I listed them for examples and I mentioned that for my knowledge I dont think I can do it at the moment.
Batch processing seems to be useful for me, but does it only work effectively for renaming multiple similar files?

Batch processing doesn’t know about the files. It operates on the selected items. That could be one file or a hundred. And the actions you use are up to you as well. You could completely change the name of all the selected files without regard to their current name, e.g., DSC_20241107-104454.png could be renamed to Happy Dogs 001.png.

1 Like

Batch processing is basically just an ad hoc way to fire off a custom smart rule on selected items. It remembers the last used settings, but if you’re gonna use the same settings regularly, you are better off setting up a Smart Rule. Then it will also trigger automatically, according to the criteria you define.

If you already have a rule set up, instead of letting it trigger automatically, you can also right click one item or a selection of multiple and choose Apply Rules > [List of smart rules, choose one]

Here is how to think about automation in DEVONthink…

1 Like

that is helpful, certainly I need to understand more about placeholder;
I will get back to this discussion once I need more assistance
thanks

There’s also a section on Smart Rules in the chapter Automation, and a full list of the different options under Appendix > Smart Rule Events and Actions


To give you an idea, this is the same as your example in the opening post:

Batch Process: Change Name

Where _Syllabus_ is manually entered, and Name is the original item name. I got Creation Year from Insert Placeholder > Creation Date > Year

… Oh, I guess I am missing the “Change Case” to “Title Case”. But DEVONthink comes with a Change Case script, found in the script folder Rename. You can either use that before you batch process, or you can incorporate it directly in a Smart Rule.

1 Like

I found that intriguing when I insert placeholder, this could actually be my lifesaver.
There are some terms that I do not quite understand the difference
for example:

  • name vs. proposed name vs. name without date

Are there any documentation specifying these terms?

One more thing:
I saw the AppleScript of downloading DOI, which means there may be a possibility that devonthink can be a reference manager.
I wonder how does that work if the workflow is based on APA format, would that be possible by using smart rule to change name to [year] - [author] - [title], and would that be easy to extract either the APA formatted reference or citation?

and also:
suppose I want to replace / delete text from the file name, what should I do? or how do I let devonthink detect them?
by defining a string? or something else?

Are there any documentation specifying these terms?

Again, check the manual. Look at the Appendix.

2 Likes

I actually already told you where the placeholders are documented:

In general the Appendix is where you will find descriptions of all the different options and details not explicitly covered elsewhere.

For renaming/manipulating the original filename, it depends. There are several options.

  • For example, the Name without date placeholder is the original filename with any dates removed.

  • In the Rename script folder, there are the scripts Rename using RegEx and Replace Text…

  • Most likely, you want to use the Scan Name action in a Smart Rule or Batch Process. This lets you specify a string to capture in the filename, and you can then insert a placeholder representing this string in Change Name.

    You can choose “String”, “Date” and “Amount” – or for more complex captures, you can use Regular Expression/RegEx.

    See p. 252 of the manual (3.9.8 version); Appendix > Smart Rule Events and Actions > Actions > Item Scanning.

The DOI/Google Books Metadata scripts fetch metadata and puts it into Custom Metadata fields (only available in DEVONthink Pro and Server). Since Custom Metadata fields are available as placeholders, it is quite easy to use them for renaming :slight_smile:

Using DEVONthink as a reference manager? That is a quite different and more complicated topic. I think it makes more sense to discuss in its own thread.

It depends on what you expect of a reference manager – and how much work you’re willing to put into learning how to script it. Potentially yes, more likely no. Dedicated reference managers exist for a reason.

I do remember reading some people here in the forum actually use it as a simple reference manager. Try and search around.

1 Like

Maybe take a look at this:

It has since been made officially available inside the app. You install it through the Support Assistant.

It will put a formatted reference in the “Finder Comments” field. The citation format can be customised – read the comments in the script itself. It is easy, you just change the line set CitationName to. There are different APA variants, so find the one you want in the link given in the script.

1 Like