Applescript - Lock Finder selection [closed]

I found scripts that lock a file w/ a specific path but none that lets me "lock the selected item/s in the Finder".

Could sb give me a hand with this?

Much appreciated.


The following example AppleScript code will set the locked property of selected items in Finder to true:

tell application "Finder"
    repeat with thisItem in (get selection)
        set locked of thisItem to true
    end repeat
end tell

NOTE: The filesystem of the container has to support the locked property of the selected items. As an example, an ExFAT volume does not support the locked property on folders but it does for files. Whereas on a HFS+ or APFS volume it supports it for both files and folders.