Thursday, 15 August 2019

macos - Command to unlock "Locked" files on OS X


I copied a lot of read-only files from a Windows system to my Mac. When viewing the Info for each file using "Get Info", I can see they are Locked. I'm writing a bash script to copy over some files and I'm getting an error that says "Operation not permitted" So, first I need to unlock the files. Since I'll be pulling files from the Windows system often, I want my script to unlock these files.


What is the terminal command to unlock "Locked" files on OSX?



Answer



To unlock files you can use:


chflags -R nouchg /PATH/TO/DIRECTORY/WITH/LOCKED/FILES/


  • chflags = change flags on files/folders such as "locked"

  • -R = recursive or for everything and follow directories within the specified directory

  • nouchg = means the file can be changed

  • /PATH/ = of course is the path to the files you want to change. Something like: ~/Sites/mysite/directory/with/locked/files/ works as well.


No comments:

Post a Comment

How can I VLOOKUP in multiple Excel documents?

I am trying to VLOOKUP reference data with around 400 seperate Excel files. Is it possible to do this in a quick way rather than doing it m...