Windows – Compress each file in folder into 7z archive. Keep modified date and delete original.
for /f %i in ('forfiles /D -12/31/2011 /c "cmd /c echo @FILE"') do @7z a Archives/%~i.7z %~i -mmt=on -sdel -stl
- Command is to be ran at same folder you want to compress every file into a single 7z.
- Forfiles /D will only select files older than specified date.
- It will place each 7z into Archives subfolder.
- Keeps the date of the file inside as archive date.
- “-sdel” Delete file when done.