Situatie
You’ll set up a Windows Task Scheduler job that runs a PowerShell script. The script finds files not accessed in, say, 90 days, compresses them into a ZIP archive, and moves them to an “Archive” folder. You retain the files but reduce live disk usage.
Solutie
Prerequisites
-
Windows 10 or Windows 11 with admin rights.
-
PowerShell (built in).
-
Enough disk space to initially create the ZIP archive.
Files & variables (example)
Steps
-
Create Archive Folder
-
Create
D:\Archive\OldFiles(or your target). -
Ensure you have write permissions.
-
-
Save the PowerShell script (e.g.,
C:\Scripts\CompressOldFiles.ps1): -
Open Task Scheduler
-
Create a new task → Give it a name like “Compress Old Files”.
-
Trigger: daily (choose a time when PC is on).
-
Action: Start a program →
powershell.exe-
Add arguments:
-File "C:\Scripts\CompressOldFiles.ps1" -SourceFolder "C:\Users\Public\LargeFiles" -ArchiveFolder "D:\Archive\OldFiles" -DaysThreshold 90
-
-
Conditions: maybe only if idle or if on AC power.
-
-
Test it
-
Manually run the task and check you get a ZIP file in the Archive folder.
-
Verify disk space is freed.
-
Adjust
DaysThresholdif you want older/newer files.
-
Troubleshooting & notes
-
If you get permission errors, check that your user account or the scheduled task’s user has read access to the source and write to archive.
-
Large archives can take time — monitor task duration.
-
Consider how long you want to keep archives. You might add a cleanup step (e.g., delete archives older than X days).
-
This doesn’t replace a proper backup: archived files are still on disk (or same machine) so risk remains if drive fails.
Leave A Comment?