Is there a way to batch rename pdf files in DT?
See menu Scripts > Rename > …
Unless I’m missing something using the Replace Text I have to enter the text to replace first? How does this work with multiple files with different names that I want to change to be the same name? Or better yet change them all to the same name with an added _01 or A,B,C after the name I choose?
Will batch rename change in 2.0?
No. But this can be easily scripted.
OK, but what if you’re a doofus with scripting (like me)?
It seems like a simple replace text (with the files selected to rename) without the search would do the trick for renaming.
I’m not sure what “without the search” should be or do but the “Replace Text” script supports multiple selected files.
if you just want to change the names to a specific name followed by a suffix, that’s pretty easy.
tell application "Devonthink Pro"
set theSelection to the selection
set theCounter to 0
repeat with thisSelection in theSelection
set theCounter to theCounter + 1
set the name of thisSelection to "replace me" & theCounter
end repeat
end tell
Just put the items in the order that you want, select them all, and run this script in Script Editor.
Sorry for the terseness, I’m on my iPhone.
The Scripts menu includes Rename/Add Prefix and Rename/Add Suffix scripts. At least mine does. IIRC, these work with groups of selected files. (That is, they add the same prefix or suffix to each file in a group.)
Katherine
Thanks for the script. So to use that multiple times for different renames I would have to go into the script every time to choose the new names right? (or make multiple scripts).
I guess I’m used to replacing text in apps like Adobe Bridge where you select the files with names you want to change then have options for the new naming.
This might be too robust for DT, but it does add a lot of options.
Yes the suffix and prefix add to what’s already there.
But if you want to totally delete what’s already there using just Replace it first asks you to “Enter text to find in the file names”. What if the file names have different text? I would like it to just replace the text that’s already there with what I choose.
The script submitted above does that but I’m seeing that I’d have to go into the script for every batch rename.
OK I tried this by cutting and pasting from the existing script and the one submitted above. But of course since I have no idea of the correct syntax, it doesn’t work!
tell application "DEVONthink Pro"
set this_selection to the selection
display dialog "Enter replacement text:" default answer "" buttons {"Cancel", "OK"} default button 2
set replacement_string to the text returned of the result
set theCounter to 0
repeat with thisSelection in theSelection
set theCounter to theCounter + 1
end repeat
end tell
I would also be happy to have this script …
Basically only one line is missing, this one should work:
tell application "DEVONthink Pro"
set theSelection to the selection
if theSelection is not {} then
display dialog "Enter name:" default answer "" buttons {"Cancel", "OK"} default button 2
set theName to the text returned of the result
set theCounter to 0
repeat with theRecord in theSelection
set theCounter to theCounter + 1
set name of theRecord to theName & (theCounter as string)
end repeat
end if
end tell
cool, thank you cgrunenberg!
I just removed this:
& (theCounter as string)
So it’s not numbering the changes.
cheers
m.