Skip to content

Instantly share code, notes, and snippets.

@yanonono
Created March 21, 2022 06:59
Show Gist options
  • Select an option

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

Select an option

Save yanonono/066f520a6803028a0aeb0ae9c56e2316 to your computer and use it in GitHub Desktop.
フォルダをzip化するPowerShell

フォルダをzip化するPowerShell

# フォルダ名+".zip"でzip化
Get-ChildItem ./ -Directory | Where-Object {
$dirname = Split-Path $_ -Leaf
$zipFile = ".\{0}.zip" -f $dirname
Compress-Archive -Path $_ -DestinationPath $zipFile
}
# フォルダ名+(フォルダの最終更新日時)+".zip"でzip化
Get-ChildItem ./VRChat* -Directory | Where-Object {
$lastUpdate = $(Get-ItemProperty $_).LastWriteTime.ToString("yyyyMMdd_HHmmss")
$dirname = Split-Path $_ -Leaf
$zipFile = ".\{0}.{1}.zip" -f $dirname, $lastUpdate
Write-Output $zipFile
Compress-Archive -Path $_ -DestinationPath $zipFile
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment