Cleaning up old files is an incredebly annoying operation. It’s time consuming and might result into errors due to repeating the same actions all the time. However, it’s necessary to remove old files in order to keep your folder clear and gain free space on your hard disk.


The best solution to clean up old files while saving time and avoiding mistakes is to automate the process using a sophisticated program or a simple script.
For this occasion, i’m glad to present Archivator, my script for archiving old files. It searches a particular folder to compress old files using 7zip then move them to another directory. It simple to understand and easy to customize.

Follow these steps to make use of it:

  1. Download 7Zip from this the official link
  2. Install it to your C:\Program Files\7-Zip\
  3. Download Archivator from my github
  4. Open Windows Powershell and update the execution policy using this command: set-executionpolicy bypass
  5. Navigate to where archivator script have been saved using cd command in windows powershell.
  6. Archivator takes command lines in this format
1
.\Archivator -FilesPath "PathToYourFiles" -FileExtension "TypeOfFileToArchive" -DaysToKeep X -ArchivePath "PathToMoveZippedFilesInto"

For example, this command will zip all txt files in D:\Extracts older than from J-3 and move them to D:\Extracts\Archive\dd-MM-YY

1
.\Archivator -FilesPath "D:\Extracts\" -FileExtension "*.txt" -DaysToKeep 3 -ArchivePath "D:\Extracts\Archive"
  1. You can copy your command and paste it in a bat file that you can later use to create a scheduled task inside the task scheduler.