我有遵循这样的模式的文件夹:
C:\
└───root
├───V16
│ ├───1
│ │ A.sql
│ │ B.sql
│ │
│ ├───2
│ │ C.sql
│ │
│ └───4
│ E.sql
│
└───V17
└───1
D.sql
我的目标是获得这种模式:
C:\root\V16-1\A.sql
C:\root\V16-1\B.sql
C:\root\V16-2\C.sql
C:\root\V17-1\D.sql
C:\root\V17-4\E.sql
我完全知道如何在 C# 中做到这一点,但不幸的是我真的是 powershell 的新手
试试这个
$DirToRemove=@()
Get-ChildItem "C:\temp\root\*\*" -directory | %{
move-Item $_.FullName ($_.Parent.FullName + '-' + $_.Name)
$DirToRemove+=$_.Parent.FullName
}
$DirToRemove | select -Unique | Remove-Item
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句