Skip to content

Instantly share code, notes, and snippets.

@kpatnayakuni
Created February 6, 2020 16:49
Show Gist options
  • Save kpatnayakuni/f969b234ae6cf729c3d2d7c8d283c350 to your computer and use it in GitHub Desktop.
Save kpatnayakuni/f969b234ae6cf729c3d2d7c8d283c350 to your computer and use it in GitHub Desktop.
$FolderName = "C:\Temp1"
$DestinationPath = "C:\Temp2"
$Dates = Get-ChildItem -Path $FolderName -ErrorAction SilentlyContinue | Select-Object -Property @{Name = "CreationTime"; Expression = { $_.CreationTime.Date } } -Unique
$Files = Get-ChildItem -Path $FolderName -ErrorAction SilentlyContinue
foreach ($Dt in $Dates.CreationTime) { $Files | Where-Object { $_.CreationTime.Date -eq $Dt } | Compress-Archive -DestinationPath "$DestinationPath\$($Dt.ToString("MMM_yyyy")).zip" -Force }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment