How to Set or Unset Read-only Attribute of Files and Folders in Windows 10
In Windows, you can set or unset the read-only attribute for files and folders to give files write protection.
Folders cannot actual be set as read-only though. Only files in the folder will be set as read-only instead.
When a file (ex: text file) is set as read-only, the file can no longer be altered since it no longer allows write permission. You will still be able to save your changes to the file as a new file though.
This tutorial will show you different ways on how to set or unset the read-only attribute of files and folders in Windows 10 and Windows 11.
Read-only box = Not read-only. Neutral setting of a folder that is always displayed by default.
Read-only box = File is currently read-only. Only displays temporarily for a folder while setting to be applied to files in folder.
Read-only box = File is currently not read-only. Only displays temporarily for a folder while setting to be applied to files in folder.
Contents
- Option One: To Set Read-only Attribute of Files and Folders from Properties
- Option Two: To Unset Read-only Attribute of Files and Folders from Properties
- Option Three: To Set Read-only Attribute of File using Command Prompt
- Option Four: To Unset Read-only Attribute of File using Command Prompt
- Option Five: To Set Read-only Attribute of All Files in Folder and Subfolders using Command Prompt
- Option Six: To Unset Read-only Attribute of All Files in Folder and Subfolders using Command Prompt
- Option Seven: To Set Read-only Attribute of File using PowerShell
- Option Eight: To Unset Read-only Attribute of File using PowerShell
- Option Nine: To Set Read-only Attribute of All Files in Folder and Subfolders using PowerShell
- Option Ten: To Unset Read-only Attribute of All Files in Folder and Subfolders using PowerShell
EXAMPLE: File is set to read-only message
1 Open File Explorer (Win+E).
2 Select one or more files and/or folders you want to set as read-only, right click or press and hold on the selected items, and click/tap on Properties. (see screenshot below)
3 In the General tab, check the Read-only box in the bottom Attributes section, and click/tap on OK. (see screenshots below)
4 If you selected a folder, select (dot) to either Apply changes to this folder only or Apply changes to this folder, subfolders and files for what you want, and click/tap on OK. (see screenshots below)
Apply changes to this folder only will only not be grayed out if you selected other files or folders in addition with this folder.
If you select (dot) Apply changes to this folder only, any selected folders and their contents will be ignored.
1 Open File Explorer (Win+E).
2 Select one or more files and/or folders you want to unset as read-only, right click or press and hold on the selected items, and click/tap on Properties. (see screenshot below)
3 In the General tab, uncheck the Read-only box in the bottom Attributes section, and click/tap on OK. (see screenshots below)
4 If you selected a folder, select (dot) to either Apply changes to this folder only or Apply changes to this folder, subfolders and files for what you want, and click/tap on OK. (see screenshots below)
Apply changes to this folder only will only not be grayed out if you selected other files or folders in addition with this folder.
If you select (dot) Apply changes to this folder only, any selected folders and their contents will be ignored.
1 Open a command prompt or elevated command prompt based based on the access permissions you have for the file.
2 Type the command below into the command prompt, and press Enter. (see screenshot below)
attrib +r "full path of file with extension"
Substitute full path of file with extension in the command above with the actual full path of the file you want to set as read-only.
For example:attrib +r "C:\Users\Brink\Desktop\Folder\File1.txt"
1 Open a command prompt or elevated command prompt based based on the access permissions you have for the file.
2 Type the command below into the command prompt, and press Enter. (see screenshot below)
attrib -r "full path of file with extension"
Substitute full path of file with extension in the command above with the actual full path of the file you want to unset as read-only.
For example:attrib -r "C:\Users\Brink\Desktop\Folder\File1.txt"
1 Open a command prompt or elevated command prompt based based on the access permissions you have for the folder.
2 Type the command below into the command prompt, and press Enter. (see screenshot below)
attrib +r "full path of folder\*" /s /d
Substitute full path of folder in the command above with the actual full path of the folder you want to set read-only for all files in this folder and its subfolders.
For example:attrib +r "C:\Users\Brink\Desktop\Folder\*" /s /d
1 Open a command prompt or elevated command prompt based based on the access permissions you have for the folder.
2 Type the command below into the command prompt, and press Enter. (see screenshot below)
attrib -r "full path of folder\*" /s /d
Substitute full path of folder in the command above with the actual full path of the folder you want to unset read-only for all files in this folder and its subfolders.
For example:attrib -r "C:\Users\Brink\Desktop\Folder\*" /s /d
To see more usage options for the Set-ItemProperty command, see: Set-ItemProperty - Microsoft Docs
1 Open PowerShell or elevated PowerShell based on the access permissions you have for the file.
2 Type the command below into PowerShell, and press Enter. (see screenshot below)
Set-ItemProperty -Path "full path of file with extension" -Name IsReadOnly -Value $True
Substitute full path of file with extension in the command above with the actual full path of the file you want to set as read-only.
For example:Set-ItemProperty -Path "C:\Users\Brink\Desktop\Folder\File1.txt" -Name IsReadOnly -Value $True
To see more usage options for the Set-ItemProperty command, see: Set-ItemProperty - Microsoft Docs
1 Open PowerShell or elevated PowerShell based on the access permissions you have for the file.
2 Type the command below into PowerShell, and press Enter. (see screenshot below)
Set-ItemProperty -Path "full path of file with extension" -Name IsReadOnly -Value $False
Substitute full path of file with extension in the command above with the actual full path of the file you want to unset as read-only.
For example:Set-ItemProperty -Path "C:\Users\Brink\Desktop\Folder\File1.txt" -Name IsReadOnly -Value $False
To see more usage options for the Get-ChildItem command, see: Get-ChildItem - Microsoft Docs
1 Open PowerShell or elevated PowerShell based on the access permissions you have for the folder.
2 Type the command below into PowerShell, and press Enter. (see screenshot below)
Get-ChildItem -Path "full path of file with extension" -Recurse -File | % { $_.IsReadOnly=$True }
Substitute full path of file with extension in the command above with the actual full path of the folder you want to set read-only for all files in this folder and its subfolders.
For example:Get-ChildItem -Path "C:\Users\Brink\Desktop\Folder\File1.txt" -Recurse -File | % { $_.IsReadOnly=$True }
To see more usage options for the Get-ChildItem command, see: Get-ChildItem - Microsoft Docs
1 Open PowerShell or elevated PowerShell based on the access permissions you have for the folder.
2 Type the command below into PowerShell, and press Enter. (see screenshot below)
Get-ChildItem -Path "full path of file with extension" -Recurse -File | % { $_.IsReadOnly=$False }
Substitute full path of file with extension in the command above with the actual full path of the folder you want to unset read-only for all files in this folder and its subfolders.
For example:Get-ChildItem -Path "C:\Users\Brink\Desktop\Folder\File1.txt" -Recurse -File | % { $_.IsReadOnly=$False }
That's it,
Shawn Brink
Related Tutorials
- How to Add a File Attributes context menu in Windows 10
- How to Enable or Disable Write Protection for a Disk Drive in Windows
- How to Turn On or Off Write Protection for Removable Drives in Windows 10
- How to Set or Unset Hidden Attribute of Files and Folders in Windows 10