Conditionally re-index files on network share

I am on macOS and mount some network shares to a directory in my user folder


I index some folders on that share, e.g.


When the share is not mounted and DT re-indexes it removes all indexed files from the database as the indexed folder does not exist anymore. When the share is mounted again and the re-index runs all files appear again. Is there a way to prevent this, i.e. to re-index only when some condition (e.g. when the indexed folder is existing) is met (maybe this condition can be checked with a script).


How did you mount that share? Usually all volumes have a path beginning with /Volumes/ and that’s supported by DEVONthink.

As macOS Sierra requires root-priviliges to write to /Volumes (i.e. asking me for my password) I changed to user-writable location. See this for more info:

I mount via

mount_smbfs \"//user:password@server/shareA\" ~/mnt/shareA

You can mount shares into /Volumes (which is the default/recommended location) from the command line without specifying your password (provided you have mounted the share once via Finder and specified to save your credentials in your keychain) using some AppleScript inside a shell script. Here’s a simplistic example:

declare -i ret=0
if [ $# != 1 ]
echo “error: missing share URL”
exit 1
/usr/bin/osascript >& /dev/null <<!!!
mount volume “$1”
end try
if [ $? -ne 0 ]
echo “error: failed to mount ‘$1’”
exit ${ret}

Save this as ‘mountShare’ (or whatever name you like) in /usr/local/bin and make it executable (chmod 755 /usr/local/bin/makeShare). Then you can mount your share by doing:

mountShare “”//server/shareA"

and it will get mounted as /Volumes/shareA