DT indexed folder relocation

I have DT indexed folders on local USB drive, e.g. ~/disk/documents, when I want to relocate such indexed folder one layer down to ~/disk/backup/documents, without other changes, how to tell DT the new location and avoid re-indexing the folders, since nothing change except the directory?


You could create an empty folder ~/disk/backup in the Finder and index this folder to the same database afterwards. Finally move the indexed group documents inside DEVONthink into the indexed group backup.

I have multiple databases associated to DT indexed folders, will this end up to one huge database for the indexed group backup? e.g. db1 for indexed folder1, db2 for indexed folder2…

Should all of these folders in different databases be moved to the same enclosing folder (backup in your example)?

In this case the above procedure won’t work and a script would be necessary like this one:

-- Update Paths.
-- Created by Christian Grunenberg on Fri May 17 2019.
-- Copyright (c) 2019. All rights reserved.

tell application id "DNtp"
		set this_selection to the selection
		if this_selection is {} then error "Please select some items."
			display dialog "Find:" default answer "" buttons {"Cancel", "OK"} default button 2
			set searchString to the text returned of the result
			if searchString is not "" then exit repeat
		end repeat
		display dialog "Replace:" default answer "" buttons {"Cancel", "OK"} default button 2
		set replacementString to the text returned of the result
		if searchString is not equal to replacementString then
			show progress indicator "Updating Paths..."
			my updatePaths(this_selection, searchString, replacementString)
			hide progress indicator
		end if
	on error error_message number error_number
		hide progress indicator
		if the error_number is not -128 then
				display alert "DEVONthink" message error_message as warning
			on error number error_number
				if error_number is -1708 then display dialog error_message buttons {"OK"} default button 1
			end try
		end if
	end try
end tell

on updatePaths(theseRecords, theSearch, theReplacement)
	local this_record, this_path
	tell application id "DNtp"
		repeat with this_record in theseRecords
			step progress indicator (name of this_record as string)
			set this_path to (path of this_record as string)
			if this_path is not "" then set the path of this_record to my replaceString(this_path, theSearch, theReplacement)
			my updatePaths(children of this_record, theSearch, theReplacement)
		end repeat
	end tell
end updatePaths

on replaceString(theString, theOriginalString, theNewString)
	set {od, AppleScript's text item delimiters} to {AppleScript's text item delimiters, theOriginalString}
	set theStringParts to text items of theString
	if (count of theStringParts) is greater than 1 then
		set theString to text item 1 of theStringParts as string
		repeat with eachPart in items 2 thru -1 of theStringParts
			set theString to theString & theNewString & eachPart as string
		end repeat
	end if
	set AppleScript's text item delimiters to od
	return theString
end replaceString

E.g. use something like /the/old/path for the find string and /the/new/path/is/here for the replace string but please try this using an indexed test group first.

Thank you and I will save it for later try.

I have taken the index-empty-folder approach, and replicate all existing indexed folders (which as groups in DT databases) to the new location (e.g. ~/disk/backup/), and repeat the “move” process one folder at a time in each database, just to avoid the reindexing process. With 3 dozen folders allocated to 10 databases, it is some no-kidding work for about 2 hours. Is there a MUST reason for this above-average-effort for DT database to point to new location…

There is “Path” info in the Database/Group Inspector, in the future is it possible for user to alter new location here followed by “Update indexed items” for such purpose.

Is there a MUST reason for this above-average-effort for DT database to point to new location…

How about because indexing should be carefully and cautiously considered, not something to be used lightly?

1 Like

Another typical scenario is to backup indexed folders and DT databases to a second or third disk/location, and not necessarily the exact same PATH/Dir for the indexed folders at the new locations - in such case, what is the best practice? or when you install a second DT seat on a new Mac but want to reuse part or all of the existing indexed folders/databases, do you have to reindex such folders again on the new Mac?

– ideally DT database is about document/data(index, metadata etc.) and its relationships (tag, link, note etc.) and would be better off without worrying about locations (leave such mess to Finder or OS)

I don’t know how typical it is to backup data and the path doesn’t remain the same, but DEVONthink handles indexed backups and a second seat on a new Mac perfectly as long as the path is unchanged.

I use Calibre as e-book management tool and maintain multiple libraries as well. As long as you point Calibre to the new location you are choosing, the library itself is intact and no worries, the new location could be local disk, cloud, usb or whatever path/dir you are comfortable with - in short its library maintenance is “independent” from user preferred location. Every product has its own development path, so it’s totally fine as long as there is solution for certain issue, and meet most expectations:-)