powershell - 如何在PowerShell中递归查找包含.hg文件夹的所有文件夹

标签 powershell mercurial

我正在尝试在 PowerShell 中编写一个脚本来备份我们的 Mercurial 存储库集合。

我是从这个开始的:

$repos=Get-ChildItem C:\hgrepos|Where-Object { $_.PSIsContainer }

这将获得 C:\hgrepos 下的第一级文件夹,这通常没问题,因为这是我们的存储库所在的位置。但是,存在子存储库。所以我需要递归。最重要的是,只应列出包含 .hg 子文件夹的文件夹

最佳答案

您可以在 Get-ChildItem

中使用 -recurse 标志

会是这样的:

gci c:\hgrepos -recurse -include ".hg" | %{$_.Parent}

关于powershell - 如何在PowerShell中递归查找包含.hg文件夹的所有文件夹,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9092194/

相关文章:

System.Net.WebException 的 Powershell 处理

windows - FORFILES date -after-(cmd 文件中的日期计算)

windows - 如何从 PowerShell 中的 dir 命令中删除当前路径?

java - 从存储库同步中删除/bin文件夹

Mercurial .hgrc文件

powershell - 我可以在Powershell中自定义 'not recognized as the name of a cmdlet'错误吗?

PowerShell 模拟到 "dir/a:d"(Win) 或 "ls -d */"(Bash)

mercurial - 在 Mercurial 中指定 Hook 时是否可以指定要使用的 Windows shell?

linux - mercurial 1.9 和 ssh 的问题

mercurial - 移动 .hg 文件夹