This tutorial will show you different ways to set or unset the read-only attribute for files and folders in Windows 10 and Windows 11.
You can set or unset the read-only attribute for files and folders to give files write protection.
When setting a folder as read-only, read-only is actually only applied to all files in the folder and subfolders instead. A folder itself will not be read-only.
When a file is set to be read-only, write permissions are removed. This prevents the file from being edited or modified. For example, any edits to a read-only text file will have to be saved as a new file.
You will still be able to delete a read-only file.
Reference:
attrib
- Option One: Set or Unset File as Read-only from File Properties
- Option Two: Set or Unset All Files in Folder and Subfolders as Read-only from Folder Properties
- Option Three: Set or Unset File as Read-only using attrib Command
- Option Four: Set or Unset All Files in Folder and Subfolders as Read-only using attrib Command
- Option Five: Set or Unset File as Read-only in PowerShell
- Option Six: Set or Unset All Files in Folder and Subfolders as Read-only in PowerShell
EXAMPLE: File set to read-only message
1 Right click on a file you want, and click/tap on Properties.
2 In the General tab, check (set) or uncheck (unset - default) the Read-only attribute for what you want. (see screenshots below)
3 Click/tap on OK.
1 Right click on a folder you want, and click/tap on Properties.
2 In the General tab, check (set) or uncheck (unset - default) the Read-only attribute for what you want, and click/tap on OK. (see screenshots below)
3 Click/tap on OK to Apply changes to this folder, subfolders and files. (see screenshots below)
1 Open Terminal or Terminal (Admin) based on the access permissions you have for the file, and select either Windows PowerShell or Command Prompt.
2 Type the command below you want to use into Terminal, and press Enter. (see screenshots below)
attrib +r "<full path of file with extension>"attrib -r "<full path of file with extension>"Substitute <full path of file with extension> in the commands above with the actual full path of the file you want to set or unset as read-only.
For example: attrib +r "C:\Users\Brink\OneDrive\Desktop\File.txt"
1 Open Terminal or Terminal (Admin) based on the access permissions you have for the folder, and select either Windows PowerShell or Command Prompt.
2 Type the command below you want to use into Terminal, and press Enter. (see screenshots below)
attrib +r "<full path of folder>\* /s /d"attrib -r "<full path of folder>\* /s /d"Substitute <full path of folder> in the commands above with the actual full path of the folder you want to set or unset all files in the folder and subfolders as read-only.
For example: attrib +r "C:\Users\Brink\OneDrive\Desktop\Folder\* /s /d"
1 Open Terminal or Terminal (Admin) based on the access permissions you have for the file, and select Windows PowerShell.
2 Type the command below you want to use into Terminal, and press Enter. (see screenshots below)
Set-ItemProperty -Path "<full path of file with extension>" -Name IsReadOnly -Value $TrueSet-ItemProperty -Path "<full path of file with extension> -Name IsReadOnly -Value $False"Substitute <full path of file with extension> in the commands above with the actual full path of the file you want to set or unset as read-only.
For example: Set-ItemProperty -Path "C:\Users\Brink\OneDrive\Desktop\File.txt" -Name IsReadOnly -Value $True
1 Open Terminal or Terminal (Admin) based on the access permissions you have for the folder, and select Windows PowerShell.
2 Type the command below you want to use into Terminal, and press Enter. (see screenshots below)
Get-ChildItem -Path "<full path of folder>" -Recurse -File | % { $_.IsReadOnly=$True }Get-ChildItem -Path "<full path of folder>" -Recurse -File | % { $_.IsReadOnly=$False }Substitute <full path of folder> in the commands above with the actual full path of the folder you want to set or unset all files in the folder and subfolders as read-only.
For example: Get-ChildItem -Path "C:\Users\Brink\OneDrive\Desktop\Folder" -Recurse -File | % { $_.IsReadOnly=$True }
That's it,
Shawn Brink











