Skip to content

Instantly share code, notes, and snippets.

@yanonono
Last active October 4, 2019 04:23
Show Gist options
  • Select an option

  • Save yanonono/d15b5eb9869a4249b8e2df363098dd07 to your computer and use it in GitHub Desktop.

Select an option

Save yanonono/d15b5eb9869a4249b8e2df363098dd07 to your computer and use it in GitHub Desktop.
同じディレクトリ内のディレクトリをzipファイル(+更新日付)を作成する
Get-ChildItem -Directory | ForEach-Object{
$zipFilename = "{0}-{1}.zip" -f $_.Name, ($_.LastWriteTime).ToString("yyyyMMdd_HHmmss")
if(Test-Path($zipFilename)) {
Write-Host "Already ZIP File :" $_.Name
} else {
Write-Host "ZIP Compressing : $_.Name -> $zipFilename"
Compress-Archive -Path $_.FullName -DestinationPath $zipFilename -CompressionLevel Optimal
}
}
Read-Host "Complete!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment