我注意到,无论是cmd
也powershell
可以做带有隐藏属性的文件递归搜索文件。
那么有什么办法解决吗?我的意思是除了必须从一个或多个有问题的文件中删除隐藏属性外,我需要事先知道它们的位置,这当然会使整个练习变得毫无意义。
为什么不能使用具有hidden属性的文件?这是某种安全功能吗?
范例(cmd)
C:\>dir /b
Intel
PerfLogs
plant
Program Files
Program Files (x86)
Users
Windows
C:\>cd plant
C:\plant>dir /b
banana.txt
C:\plant>attrib banana.txt
A C:\plant\banana.txt
C:\plant>attrib -a +h banana.txt
C:\plant>dir /b
C:\plant>dir /b banana.txt
File Not Found
C:\plant>cd /
C:\>dir /b /s banana.txt
File Not Found
C:\>
要使用PowerShell列出隐藏文件,您必须使用-Force
参数。因此,通过使用,Get-ChildItem -Force -Recurse
您将获得所有文件的列表,包括隐藏文件。
Get-Help Get-ChildItem -Examples
:
Force参数将隐藏文件添加到显示中。
是的,它不直观,并且参数本身的描述不会告诉您。
对于命令行本身,它应该是dir /A
或dir /AH
仅列出隐藏文件,但是我不确定您如何搜索该输出。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句