Bulk Rename DT4: Use change to rename just based on filename

I’m using Gemini 4.5 Pro to do this.

I have successfully used the chat inspector to rename files to my specification, but when I use a similar prompt in the Batch Process…, it keeps doing the wrong thing.

Here is a snippet of my successful chat inspector conversation.

Me: Please rename this file like the following example “197705_Byte_Magazine_Vol_02-05_Interfacing” to “197705 Vol 02 No 05 Interfacing”

Bot: Okay, I can help with that. First, please tell me the current full name of the PDF document you would like me to rename according to this new pattern:

Bot: Example:
Bot: * Old: 197705_Byte_Magazine_Vol_02-05_Interfacing
Bot: * New: 197705 Vol 02 No 05 Interfacing

Bot: Once you provide the current name, I will propose the new name based on this pattern.

Me: 197705_Byte_Magazine_Vol_02-05_Interfacing

Bot: Okay, the selected PDF is “197705_Byte_Magazine_Vol_02-05_Interfacing”.

Bot: Based on the new pattern you provided (“YYYYMM Vol VV No NN Title”), the new name would be “197705 Vol 02 No 05 Interfacing”.

Bot: Shall I proceed with this new name?

Me: yes

Here is my failing bulk rename specification:

The prompt is the following:
Rename the file using the following scheme. For example “197706_Byte_Magazine_Vol_02-06_Cognitive_Robot”. rename using following the pattern “YYYYMM Vol VV No NN Title”, the new name would be “197706 Vol 02 No 06 Cognitive Robot”.

197709_Byte_Magazine_Vol_02-09_Music_and_Computers
becomes
197709 Byte Magazine Vol 02-09 Music and Computers
I expect:
197709 Vol 02 No 09 Music and Computers

I created this batch rule by duplicating the “Rename To Chat Suggestion” batch specification.

I appreciate in advice in getting the name change I expect.

I suppose I’ve been on this forum long enough now to post the first comment that follows naming requests like yours: why are you using AI for this instead of DT’s internal scripting? All the info you want in the new file name appears to be in the old file name?

3 Likes

Because it’s a first step in learning to harness AI in DEVONthink. I could also use a shell script, but if I could learn to use the chatbot interface effectively, it gives me a single focused point of control. I was expecting this to be a simple thing to do after experimenting with single files in the inspector chat interface.

Ok. For what it’s worth (nothing really, you should use your apps how you like), I think it’s strange to install an app with the capabilities that DT has and then not use the functions that the developers have put in place when you seemingly need them. DT’s smart rules are exceptionally powerful tools and some folks use them for very complicated things. Personally most mine just run file renaming actions because I haven’t thought about a more creative use for them.

I can’t advise on the AI issue but someone else will no doubt be by soon with the answer.

4 Likes

Ok. I tried a different approach. While selecting the DEVONthink 4Beta2 manual I used the chat inspector with the prompt:
Read this document and explain how to do a batch rename using the Chat suggest.

It explained that while it can rename a single file at a time, it can’t do a batch renaming. It suggested I use Find and Replace Batch Process menu.

After some chats, it explained that I would have to do a find and replace using a regular expressions in two passes. The first batch process would extract the parts and reformat them, and the second patch process would remove the remaining underscores.

I could not get the batch process rule specified correctly. The batch process specification had a single rule:

  • find & replace
  • name
  • edit - find: ^(\d{6})_Byte_Magazine_Vol_(\d{2})-(\d{2})_(.*)$
  • edit - replace: \1 Vol \2 No \3 \4

This batch process specification did not work when I tried to rename a single file.

I then ask the chat inspector with the manual selected:
How do I setup the batch rule to rename a file.

I could not get it to explain how to specify the batch process.

How do I specify a bulk name change given regular expressions? It is not obvious from skimming the manual.

After much futzing around this seems to be the answer for renaming using batch processing. I had the chat inspector answer in seconds. This took a couple of hours.

Suggestions:

  • It would be great to specify an input and output for chat like a script (details are murky).
  • The batch processing dialog is modal. This is incredibly painful when copy and pasting stuff from the chat inspector. Please make the dialog non-modal.

I agree with @MsLogica this isn’t the best use of AI, especially if you’re already adept with regular expressions and you have highly conforming filenames. Not only are you using tokens (even if minimal) but it will be much less performant at scale.

Also, you should work on your prompts. Your filename is highly structured so give the AI highly structured guidelines.

convert the name of this document: preserve the date, remove the magazine name, preserve the volume number prefixed with "Vol" and the volume number with "No", replace underscores with spaces.  Return the converted text only. No chatter.

Then use the Query Response placeholder with the Change Name action.

There already is. Have you read the Automation > Smart Item Scripts and AI Assisted Automation ?

Also, the Help assistant isn’t authoritative, i.e., it’s producing its own replies based on the info in the Help but they’re not answers we’ve curated.

1 Like

Thank you for your patience. I have used your suggested changes, and the batch processing is now working with chat.

Here is the batch process specification:

The prompt that worked was a small change to the one you provided above.
convert the name of this document: preserve the date, remove the magazine name, preserve the volume number prefixed with “Vol” and the volume number with “No”, replace underscores with spaces. Return the converted text only. No chatter.. For
Name

… where the last Name is the Name place holder.

When I ran it with your exact suggestion, the filename was changed to: “What file name do you want to change.” It was obvious that the name was not being sent to Gemini.

On another note, when you say the “Help assistant” above what do you mean. I don’t think I invoked any help assistant. I did have Gemini read the DEVONthink 4beta2 manual to give suggestions. Is this what you mean by “Help assistant”. I just want to know good places to look for info in the future.

Thanks again for the help,
Herb

You’re welcome!

sorry, I should have made a screen capture of that. The name placeholder is indeed the correct option there.

On another note, when you say the “Help assistant” above what do you mean. I don’t think I invoked any help assistant. I did have Gemini read the DEVONthink 4beta2 manual to give suggestions. Is this what you mean by “Help assistant”. I just want to know good places to look for info in the future.

There is an AI-assisted Chat inspector in DEVONthink’s built-in Help.

It’s possible (and highly recommended in this case) to use placeholders in the prompt, e.g. the Name placeholder. This avoids slow tool calls. Alternatively change the Without Document option to one of the With Document options, otherwise the Chat - Query action can’t access the contents or properties of the document.

Finally, the Chat - Query action can’t change properties on its own (contrary to the chat assistant even if it’s enabled in the settings) as it’s just a query. Therefore the prompt shouldn’t be Rename... but e.g. Suggest a name... or Convert the following name... and then use the Chat Response placeholder in the Change Name action.