Using Devonthink 2.11 I have indexed a folder on a server. Works nicely and I can now search the files in all sorts of ways. However, when I select a file, I am informed that the volume is not mounted even though it is. Quitting and restarting Devonthink does not help. I think the explanation is that the path according to Devonthink is: /Volumes/groupdirs-1/… and this is wrong. It is /Volumes/groupdirs/…
groupdirs exist (and is mounted) groupdirs-1 does not exist.
What triggered Devonthink into adding the -1? and is there a way correcting it? Not file by file, please. There are 47000 of them.
DEVONthink 2 doesn’t change paths on its own, therefore the most likely reason is that the volume’s path was indeed /Volumes/groupdir-1/ while indexing the files & folders (e.g. because there was already another volume with the same name mounted). The only workarounds would be to remove the indexed items from the database and to index them again or to use version 3 (a script could fix the paths).
Could you tell more about this script? I had a situation where I needed to fix paths for indexed items (the external drive name changed) but did it the ol’ delete-and-replace method.
Here’s a simple example replacing strings in paths, e.g. enter the old prefix ("/Volumes/groupdirs-1/") and the new one ("/Volumes/groupdirs/").
tell application id "DNtp"
activate
try
set this_selection to the selection
if this_selection is {} then error "Please select some items."
repeat
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
try
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