Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hiding the Folders Using PowerShell

Tags:

powershell

I have a master folder on my disk drive which contains 50 other folders. Now, I want to hide those 50 folders. I can simply right click and select "hide" attribute checkbox but I am looking for a faster way of doing this. Any recommendations?

Windows 8.

like image 551
john doe Avatar asked Nov 28 '22 01:11

john doe


1 Answers

The accepted answer presents a potential security issue.

By overwriting the whole Attributes bit field, please be aware that any other attribute previously defined on your file or folder (read-only, encryption, ...) will be silently removed.

Use a binary OR to prevent this behavior:

Get-Item .\your_folder -Force | foreach { $_.Attributes = $_.Attributes -bor "Hidden" }
like image 190
Mathieu Renda Avatar answered Jun 14 '23 16:06

Mathieu Renda