Rename based on content

Hi,

Is there a relatively simple way to rename files based on content?

I currently use Hazel to look inside searchable PDFs and rename e.g. 2015-02-22_0123.pdf to Acme invoice 2015-02-18.pdf (yes, that includes pulling the invoice date out of the file).

It all works great, but the only issue I have is that it’s a long-winded process of sequential automation tools stepwise moving files from folder to folder, app to app: Scan, backup, OCR, Rename, DTPO.
It would be simpler if I could scan into DTPO and script the same result without too much trouble. Is this possible? Simplicity is key; for what it’s worth, it takes me less than 5 minutes to add a new document rule into Hazel (e.g. a new regular document, or if something changes on an existing recurring document).

Thanks,
Mike

The short answer is that there is no out-of-the-box 5 minute solution in the vein of Hazel.

Simple in the sense that the software does all the work, makes all the decisions, executes automatically, and what you get is what you get?

Or, simple in the sense that the software suggests solutions but doesn’t make decisions?

Over here, my content across thousands of documents is so varied that the first case mentioned above would be completely useless. I don’t think I’m alone.

Regarding the second case, there are some options. A simple one is that useful “Set Title As” contextual menu command that is applied against selected text

In addition, there are numerous “Rename scripts” in the support assistant or shipped with DEVONthink, or posted in the forum in the past. A older, but still useful approach is this script that Christian wrote a long time ago:

-- Automatic naming
-- Created by Christian Grunenberg on Wed Feb 20 2008.
-- Copyright (c) 2008. All rights reserved.

property pTitles : {"Time Warner", "Devon Technologies"}

tell application "DEVONthink Pro"
	set theNum to 1
	set theSelection to the selection
	repeat with theRecord in theSelection
		set theText to plain text of theRecord
		repeat with pTitle in pTitles
			if theText contains pTitle then
				set theName to pTitle & "-" & (theNum as string)
				set name of theRecord to theName
				set theNum to theNum + 1
				exit repeat
			end if
		end repeat
	end repeat
end tell

The concept here is to create a stop list of terms that, when found in a search of a document, are used to rename the document. The stop list does not need to be hard coded into the script, as it is above, but could be maintained in an external file and read into the script.

Thanks for the response. I meant simple as in simple to set up / integrate.

I did have a search around the forum before posting and looked at a couple of scripts, but it was all static and/or difficult to integrate. It’s probably possible with applescripts, but not worthwhile if it’s going to take me days to build everything from scratch.

For an example of what I currently work with, have a look at http://www.documentsnap.com/hazel-date-matching-and-choosing-the-date-to-match/. The only pain point is that it takes some time from a scan to run through my various folder automation scripts to get to DTPO, which is why I’m wondering if there’s a way to speed it up by going direct to DT and renaming there. But if it’s going to cost me a days to get working then I can live with my current setup.

Alternatively, this could be an improvement suggestion for the DT guys :slight_smile: