4

Given that locking a folder in Finder only prevents copying files into it, not changing the files inside of it!

I'm asking on behalf of a friend using macOS Mojave, who can't type, he solely uses voice recognition so terminal commands are an absolute last resort! I would only walk him through dictating those if the only other option is to spend more than $10.

Additionally, the command or utility must cause the lock symbol to appear in the Finder as well!

3
  • Can you log into their Mac from remote? Or send them a mail containing the relevant commands so they can just copy/paste?
    – nohillside
    Commented Aug 1, 2019 at 17:47
  • I could email or use Messages, I never thought of that! Commented Aug 1, 2019 at 17:54
  • What data is in these files?
    – mmmmmm
    Commented Aug 1, 2019 at 18:21

2 Answers 2

3

90% of what I do on the Mac is controlled by voice commands. It sounds like your buddy has enhanced dictation set up on his computer already. If so, if this following AppleScript code was saved in Script Editor.app as "Make Read Only.scpt" ...

tell application "Finder"
    set selectedItemsRef to a reference to (get selection)
    set itemCount to count of selectedItemsRef
    if itemCount is 1 and class of item 1 of selectedItemsRef is folder then
        set selectedFolder to (item 1 of selectedItemsRef) as alias
        set folderItemsRef to a reference to entire contents of selectedFolder

        set locked of folderItemsRef to false

        set {everyones privileges of folderItemsRef, group privileges of folderItemsRef, owner privileges of folderItemsRef} to {read only, read only, read only}

        set locked of item 1 of selectedItemsRef to false

        set {everyones privileges of selectedFolder, group privileges of selectedFolder, owner privileges of selectedFolder} to {read only, read only, read only}

        set locked of folderItemsRef to true
        set locked of item 1 of selectedItemsRef to true

    else if itemCount is 1 and class of item 1 of selectedItemsRef is document file then
        set selectedFile to (item 1 of selectedItemsRef) as alias
        set locked of selectedFile to false
        set {everyones privileges of selectedFile, group privileges of selectedFile, owner privileges of selectedFile} to {read only, read only, read only}
    end if

    if itemCount is greater than 1 then
        set selectedFolders to (items of selectedItemsRef) as alias list
        repeat with i in selectedFolders
            set folderItemsRef to (a reference to entire contents of i) --
            if locked of folderItemsRef is true then set locked of folderItemsRef to false
            if locked of i is true then set locked of i to false
            set {everyones privileges of folderItemsRef, group privileges of folderItemsRef, owner privileges of folderItemsRef} to {read only, read only, read only}
            set {everyones privileges of i, group privileges of i, owner privileges of i} to {read only, read only, read only}
        end repeat
        repeat with i in selectedItemsRef
            set locked of i to true
        end repeat
    end if
end tell

With that new "Make Read Only.scpt" script file selected in Finder and with Dictation currently active, out loud speak the phrase "Make This Speakable".

After speaking that phrase, this window should pop up.

enter image description here

Then, just as in this next image, locate and choose the file "Make Read Only.scpt"

enter image description here

enter image description here

After that new Dictation Command has been saved, you can double check that everything was done correctly by going to System Preferences / Accessibility / Dictation... Then open the Dictation Commands window and make sure your new command is in there.

enter image description here


Now after all of that setup has been completed, anytime a folder or file is selected in Finder (while enhanced Dictation is enabled and active), speak the phrase "Make Read Only". If a folder or multiple folders are selected in Finder, the Permissions of the folders and all of its contents will be set to "read only" and that the folders will be set to "locked". If only a single file is selected in Finder, it's Permissions will be set to "read only"

I have run several tests with several different scenarios and I think I have found and corrected all the bugs in the script. Be sure to test everything out a few times and let me know if you find any bugs In the code.

4
  • wch1zpink: Thank you VERY MUCH! I'm a programmer myself and spent three hours trying to write this obviously custom AppleScript myself without success. I now see why as you have used many features I was not aware where even available! Also, the instructions and pictures were invaluable as I've never before used enhanced dictation myself. Commented Aug 2, 2019 at 8:42
  • @BryanDunphy I don't know that I would consider myself a programmer. I just dabble a bit with AppleScript because ,I too, have limited use of my hands and fingers after my stroke. Basically, now I just create AppleScripts to perform pretty much anything I do on the computer... Then I make each one of those Apple scripts speakable, as I have shown in my post. Also, the SpeechRecognitionServer.app is scriptable with its own set of AppleScript commands. This allows me to create an AppleScript that will continuously listen for a set of key words or phrases, which I defined in the code...
    – wch1zpink
    Commented Aug 2, 2019 at 15:24
  • .. continued.. When it hears me speak one of those key words or phrases. I use this technique for things like entering passwords where needed or inserting my email address or home address or phone number or entering all sorts of other information into web forms or system dialogs, etc. If you feel my post has answered your question, please select it as the accepted answer and upvote it please.
    – wch1zpink
    Commented Aug 2, 2019 at 15:27
  • I just did. Also, I edited your script to reverse its effect and saved that one as another spoken command. Commented Aug 2, 2019 at 17:03
2

Select the folder of interest in Finder. Type Command - i to get info. This brings up the 'Get Info' window shown below.

enter image description here

At the bottom of the window you can see the current permissions for all enclosed files. You can then change the permissions to suit you by following the steps on the image below.

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .