Conditionally re-index files on network share

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


~/mnt/shareA

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


~/mnt/shareA/indexedFolder

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).

Thanks!

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:

https://apple.stackexchange.com/questions/245819/macos-sierra-applescript-mount-volume-keeps-asking-for-login/254097#254097

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:

#!/bin/bash
declare -i ret=0
if [ $# != 1 ]
then
echo “error: missing share URL”
exit 1
fi
/usr/bin/osascript >& /dev/null <<!!!
try
mount volume “$1”
end try
!!!
if [ $? -ne 0 ]
then
echo “error: failed to mount ‘$1’”
ret=2
fi
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