Files locked in DT but not in Finder

When I lock a file in DT, it’s never locked in Finder.
Am I doing something wrong?

Is this on indexed files?

This is intentional, it’s an internal attribute only.

Yes it is.

Is there a way to lock to files to have them “Read Only”?

Only by using a script.

I’m not able to develop such a script, do you know where I could find an example?

I find quite risky sometimes to open files that are not read-only, especially with Pages or Keynote for instance, where any change made by error is automatically saved in the original document.

This script toggles locking of record(s) and file(s). To prevent confusion I think it’s a good idea to add a marker that shows that the underlying file is locked, but I don’t know (yet) if and how you use e.g. labels. A tag could be used as marker too.

-- Toggle locking of record(s) and file(s)

tell application id "DNtp"
		set windowClass to class of think window 1
		if windowClass = viewer window then
			set theRecords to selection of window 1
		else if windowClass = document window then
			set theRecords to content record of window 1 as list
		end if
		repeat with thisRecord in theRecords
			set thisPath to path of thisRecord
			if locking of thisRecord = false then
				set locking of thisRecord to true
				tell application "Finder" to set locked of file (POSIX file thisPath as alias) to true
				set locking of thisRecord to false
				tell application "Finder" to set locked of file (POSIX file thisPath as alias) to false
			end if
		end repeat
	on error error_message number error_number
		if the error_number is not -128 then display alert "DEVONthink" message error_message as warning
	end try
end tell
1 Like

Note: Setting the locked state of a file won’t inhibit renaming in DEVONthink, just changing the file’s content.

Why not, using “Info” in Finder (or a chmod at the command line) change the file permissions to “read only” for the appropriate user/group? Messing with scripts seems over the top to me.

I finally had time to try your script @pete31… and it’s working pretty well.

Thanks a lot!

That’s quite handy! I attached a folder action script that locks all files of an indexed folder. Now I can rename those records to something meaningful. Thanks!

No problem.