Intro
Recently, I was trying to reinstall my Mac system.
Firstly, I made a copy of all my Mac files to my Synology device.
After reinstalling the macOS, I moved back all the files and saw this “lock” on every single file.
It is stupid and impossible to unlock all these files individually, let us try something quick.
Batch unlock files
Open Terminal, and go to the folder where you want to batch unlock your files.
For example
1 | cd Documents |
Then execute the below command
1 | find . -exec chflags nouchg,noschg {} \; |
find .
: This command starts a search from the current directory (.
) and includes all subdirectories.
-exec
: This option of thefind
command allows you to execute a command on each found file or directory.
chflags nouchg,noschg {} \;
: This is the command executed on each found item. It’s using thechflags
command to change file flags. Specifically, it’s removing two flags:uchg
(user immutable) andschg
(system immutable) from each file ({}
represents the current file being processed byfind
). Thenouchg
andnoschg
flags tellchflags
to remove these specific flags.Overall, this command recursively searches through the current directory and its subdirectories and removes the user and system immutable flags from all files. This can be useful if you need to modify files that are currently marked as immutable.
Done.
Reference
About this Post
This post is written by Andy, licensed under CC BY-NC 4.0.