windows CMD:如何递归删除文件和目录的“隐藏”属性

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12142350/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 09:50:19  来源:igfitidea点击:

CMD: How do I recursively remove the "Hidden"-Attribute of files and directories

windowsbatch-filecmd

提问by Searle

I can't find a command or simple batch of commands to recursively remove the "Hidden"-Attribute from files and directories. All commands like "attrib" and "for" seem to skip hidden files. E.g.:

我找不到从文件和目录中递归删除“隐藏”属性的命令或简单的批处理命令。所有像“attrib”和“for”这样的命令似乎都跳过了隐藏文件。例如:

attrib -H /S /D /L mydir

doesn't do anything at all, because it skips all hidden stuff. Does someone know how to do this with standard Windows tools?

什么都不做,因为它跳过了所有隐藏的东西。有人知道如何使用标准的 Windows 工具来做到这一点吗?

采纳答案by James K

Move the -h and specify that mydir is a directory

移动 -h 并指定 mydir 是一个目录

attrib /S /D /L -H mydir\*.*

回答by Doormatt

You can't remove hidden without also removing system.

你不能在不删除系统的情况下删除隐藏。

You want:

你要:

cd mydir
attrib -H -S /D /S

That will remove the hidden and system attributes from all the files/folders inside of your current directory.

这将从当前目录内的所有文件/文件夹中删除隐藏和系统属性。

回答by Zubair

if you wanna remove attributes for all files in all folders on whole flash drive do this:

如果您想删除整个闪存驱动器上所有文件夹中所有文件的属性,请执行以下操作:

attrib -r -s -h /S /D

属性 -r -s -h /S /D

this command will remove attrubutes for all files folders and subfolders:

此命令将删除所有文件夹和子文件夹的属性:

-read only -system file -is hidden -Processes matching files and all subfolders. -Processes folders as well

- 只读 - 系统文件 - 隐藏 - 处理匹配的文件和所有子文件夹。- 也处理文件夹

回答by Kaycii

To launch command prompt in administrator mode

在管理员模式下启动命令提示符

  1. Type cmdin Search and hold Crtl+Shiftto open in administratormode
  2. Type attrib -h -r -s /s /d "location of the drive letter:" \*.*
  1. 键入CMD在搜索不放Crtl+Shift在打开管理员模式
  2. 类型 attrib -h -r -s /s /d "location of the drive letter:" \*.*

回答by Mustafa Burak Kalkan

To make a batch file for its current directory and sub directories:

要为其当前目录和子目录制作批处理文件:

cd %~dp0
attrib -h -r -s /s /d /l *.*

回答by barter

For example folder named new under E:drive

例如在E:驱动器下名为 new 的文件夹

type the command:

输入命令:

e:\cd new

e:\new\attrib *.* -s -h /s /d

and all the files and folders are un-hidden

并且所有文件和文件夹都未隐藏

回答by user2400629

just type

只需输入

attrib -h -r -s /s /d j:*.*

where j is the drive letter...unlocks all the locked stuff in j drive

其中j是驱动器号.. 解锁 j 驱动器中所有锁定的东西

if u want to make it specific..then go to a specific location using cmd and then type

如果你想让它具体..然后使用 cmd 转到特定位置,然后键入

attrib -h -r -s /s /d "foldername"

it can also be used to lock drives or folders just alter "-" with "+"

它也可用于锁定驱动器或文件夹,只需将“-”更改为“+”

attrib +h +r +s /s /d "foldername"