「test」という名前のすべてのフォルダを見つけて、別の名前の単一フォルダにそれらを圧縮したいと思います。すべての特定のフォルダを見つけてジップします
は、私はいくつかのコードを実行するために管理:
$RootFolder = "E:\"
$var = Get-ChildItem -Path $RootFolder -Recurse |
where {$_.PSIsContainer -and $_.Name -match 'test'}
#this is assembly for zip functionality
Add-Type -Assembly "System.IO.Compression.Filesystem"
foreach ($dir in $var) {
$destination = "E:\zip\test" + $dir.Name + ".zip"
if (Test-Path $destination) {Remove-Item $destination}
[IO.Compression.Zipfile]::CreateFromDirectory($dir.PSPath, $destination)
}
それは私にエラーを与える:
Exception calling "CreateFromDirectory" with "2" argument(s): "The given path's format is not supported."
は、私が知りたい、私の$dir
のパスを渡すための正しい方法は何ですか。
ありがとう! 'フルネーム'プロペラは私に混乱していた、私はそれが実際にパスであるとは思わなかった! – Stefan0309