CMD Dir:我可以使用*代替子文件夹

CMD Dir:我可以使用*代替子文件夹,cmd,directory,subdirectory,Cmd,Directory,Subdirectory,这是我的树: 我想(只)列出各种“垃圾”文件夹中的所有文件 我尝试过这个命令,但没有成功: DIR F:\mega\*\rubbish\ 有什么建议吗?请在cmd.exe提示符下尝试 powershell -NoLogo -NoProfile -Command ^ "Get-ChildItem -Directory -Path 'F:\mega\*\rubbish'" 当然,在PowerShell控制台或.ps1文件脚本中更容易实现 Get-ChildItem -

这是我的树:

我想(只)列出各种“垃圾”文件夹中的所有文件

我尝试过这个命令,但没有成功:

DIR F:\mega\*\rubbish\

有什么建议吗?

请在cmd.exe提示符下尝试

powershell -NoLogo -NoProfile -Command ^
    "Get-ChildItem -Directory -Path 'F:\mega\*\rubbish'"
当然,在PowerShell控制台或.ps1文件脚本中更容易实现

Get-ChildItem -Directory -Path 'F:\mega\*\rubbish'
或者,这可能是为了将名称限制为“user*”子目录

Get-ChildItem -Directory -Path 'F:\mega\user*\rubbish'
要仅获取文件的完全限定路径

(Get-ChildItem -Directory -Path 'F:\mega\user*\rubbish').FullName
只能在路径的最后一个元素中使用,而不能在其他地方使用

但是,您可以使用解析子目录:

for/D%I in(“F:\mega\user*”)do@dir“%~I\bulk”
要在批处理文件中使用该代码,请不要忘记将
%
-符号加倍:

for/D%%I in(“F:\mega\user*”)do@dir“%%~I\bulk”
(Get-ChildItem -Directory -Path 'F:\mega\user*\rubbish').FullName