Create a 7z Archive for files created by date using Powershell

I have directory where various daily files gets copied. I need to write a power shell script which will create 7z archive based on groups of file create date.The name of the archive includes those group dates.

Example Below

FileA 06/23/11 FileB 06/23/11 FileC 06/24/11

Script should create 2 archives

062311.7z contains FileA, FileB 062411.7z contains FileC

Thanks in advance

--------- Now I have to develop a compression routine which can take care of daily/Weekly/ Monthly durations


The first thing you need to do is group all the files via date using group-object:

$groups = dir | group-object -property {$_.LastWriteTime.Date}

then for each group, build a command string that does your zipping and execute it:

$groups | foreach{$cmd = "7z.exe a $((Get-Date $_.Name).ToString(`"MMddyy`")).7z $([string]::join(`" `", $_.Group))"; invoke-expression $cmd}

<strong>Warning</strong>, the above is not really tested (for ex. it won't work if you spaces in your filename). But hopefully, it will give you enough to proceed.


  • How to sed a block of text with specific pattern?
  • Codeblocks' Cygwin compiler isn't working
  • How to compare one file with bunch of files in linux
  • Correctly Using Header Files?
  • Assign file names to a variable in shell
  • Ajax response not being shown inside success function
  • Standalone Cross Platform (Windows/Linux)) File Compression for C/C++?
  • How to drop columns in a compressed table?
  • Audio Sound Too Low in Android App
  • how to correctly use integration response mapping in aws api gateway to return different http codes
  • convert 16 bit grayscale DICOM image to 8 bit: the correct procedure
  • Object size discrepancy
  • Read sequential file - Compressed file vs Uncompresses
  • How enable GZIP compression for Spring HttpInvoker requests using Tomcat?
  • Animate a layout constraint by changing its priority value
  • zip lib (zlib, bzip2) and mono support
  • How to force Hadoop to unzip inputs regadless of their extension?
  • Loading a TGA File and Using it with OpenGL
  • Issue in gzip compression
  • Merge Command in R
  • Bash expand variable containing sed pattern correctly
  • Scheduling a Python Script via Windows Task Scheduler
  • Get Quarters StartDate and EndDate from Year
  • Can a MEF application built on .NET 4 import types built against .NET 3.5?
  • Java Netbeans Error Cannot find symbol, symbol: class out, location: class System, expected, illega
  • MS SQL Server 2008 :Getting start date and end date of the week to next 8 weeks
  • Aggregating two data frame columns without any existing pattern logic
  • data.table replicate rows after join?
  • Unzip archive in .Net CORE 1.0
  • Save image as is in photo album using swift
  • File extension of zlib zipped html page?
  • git add error : “fatal : malloc, out of memory”
  • DomPDF {PAGE_NUM} not on first page
  • Javascript simulate pressing enter in input box
  • Read text file and split every line in MSBuild
  • How to add a column to a Pandas dataframe made of arrays of the n-preceding values of another column
  • Importing jscolor library in angular 2
  • A cron job substitute?
  • Unit Testing MVC Web Application in Visual Studio and Problem with QTAgent
  • embed rChart in Markdown