Compress and | or delete files by mask older than N days
Script performs tasks from configuration file. It works in two modes:
-
bundledefault mode
processes files all together
result = one zip file{yyyyMMdd_HHmmss}_{filescountinbundle}{marker}.zip -
singlefor compressing large size files
processes each file separately
result = one zip per each source file{yyyyMMdd_HHmmss}_{sourcefilename}{marker}.zip)
# it takes start parameters from default config path .\config.txt
.\pacman.ps1
# or specify config file
.\pacman -config_path .\configs\config.json
- Config file contains array of dictionaries
- Each element of the array is a task
- Script processes tasks in same order as in config
- Params
arc, del, singlemay not be specified in config, default values used:arc=true, del=true, single=false - Params
path, filter, daysare mandatory - The
filterparameter is used for both compression and deletion - Filter allowes
*and?wildcards - If
days=0, script processes all files withdt < {tomorrow date 00:00:00} - If
days=1, script processes all files withdt < {today date 00:00:00} - If a critical error occured while checking parameters or performing task, the script stops and exit
[
{
"path": ".\\log",
"filter": "*.log",
"days": 31,
"comment": "bundle mode: compress all *.log files in one zip + remove *.log files older than 31 days"
},
{
"arc": true,
"path": ".\\log",
"del": true,
"filter": "????_*.log",
"days": 31,
"single": true,
"marker": "@PACMAN",
"comment": "single mode: compress filtered files separately + mark archive name with @PACMAN + remove filtered files"
},
{
"arc": false,
"path": ".\\zip",
"del": true,
"filter": "*@PACMAN.zip",
"days": 90,
"comment": "no compression, remove files by mask older than 90 days"
}
]