Default filename for merged files

I know this may sound trivial, but when you are processing a lot of files (and I am going through thousands of PDFs, merging ones that need to be merged) it slows you down a lot.

My comment concerns the way, when you merge a group of files, it names the merged file “2 merged files”, “16 merged files” etc. This means the files end up out of sequence and the only way to get them back is then to rename.

Is there any way to make it so that if you merge files called, say “fname1” and “fname2” the name for the merged files becomes something like “fname1+others” or anything that would leave the merged file in the same place in the sequence of filenames? It is not clear what the rationale behind the current default filename is.

Though I am critical of this, I would point out that without Devon Think I would not be able to have the workflow I do with my current project; it is invaluable, and I am just looking for improvements to what is already good!

Roger

The script below will merge your documents and prompt for the name of the merged file. The default name shown in the dialog is pretty much what you suggested. For example: “Name of first document - and 5 others”. The default name is based on the first document in the selection. You can override this name with anything you wish. Note that this script will save the merged document in the current group - which is usually the group of the first document in the selection.

This script will only merge the contents of RTF or PDF files. If different file types are selected, the non-RTF / non-PDF files will not be part of the new file.

tell application id "com.devon-technologies.thinkpro2"
	
	if selection is {} then error "Select some documents"
	set theSelection to selection
	set numItems to the (number of items in theSelection) - 1
	set tempName to the name of the first item of theSelection & " - and " & (numItems as string) & " others"
	set mergedName to text returned of (display dialog "What is the name for the merged documents" default answer tempName)
	set mergedRecord to (merge records theSelection in current group)
	set the name of mergedRecord to mergedName
	
end tell

I didn’t bother to search whether anyone else has posted a similar script - though the behavior @reb2012 mentions has also bothered me. His posting finally prompted me to do something about it! Thanks, Roger. :slight_smile:

Fantastic. Amazing to get such a quick and helpful response. As a total non-expert, I am pleased I even managed to get it working, by pasting into the Apple script editor, saving, and them importing into the DT script section. Moreover turns out that clicking the script menu and then on the script is just as easy as right clicking on the files and selecting merge (trivia like that matter when you are doing it repeatedly).

Icing on the cake - to save an extra mouse click, I edited the line

set mergedName to text returned of (display dialog “What is the name for the merged documents” default answer tempName)

so that it reads

set mergedName to tempName

and it still worked! (I am a newcomer to all of this.) I have now saved both versions, as it is useful to have both available.

Thank you very much. I wish I had asked before I had merged several hundred files using the other method.

Roger

Having now used the new macro dozens of times I want to say that it works really well. When it has run, the focus remains on the files that were merged, so a single keystroke can then delete them. The focus is then on the newly merged file, meaning you can immediately see that the file was correctly created, and then either tinker with it, or move on to the next. It has transformed the process of going through a folder of PDF’s, merging ones that need to be merged.

Thanks again.

Roger

I’m pleased you like it — I do too — solves an annoyance with Merge. :confused:

BTW, you can assign a keystroke to a script. Say, the script is named “Custom Merge” and you want to assign command-f12 to the script, then rename the script to

Custom Merge___Cmd-F12.scpt

That’s three underscore characters before ‘Cmd’. You can combine various control keys. This would also be valid:

Custom Merge___Shift-Ctrl-Cmd-F12

Or whatever works for you.

Change the file name, then in DEVONthink click Scripts > Update Scripts Menu Look at the name of the script in the menu, and the shortcut you specified should be displayed next to the script name. If so, then the shortcut is active.

Thanks. That is neat and will save some time.

Roger