For EDI files which need to be archived, I would like to use a compression utility (like 7Zip) which collects and compresses files based on their file date. For example, a weekly archive (incoming-2009-01.7z for week 1) needs to be updated with all incoming files whose file date is in this week.
Is there a command line utility which can be used to invoke a compression tool with the necessary arguments, or an other easy way to implement such an archive strategy?
I don't know of a utility that provides this directly but it's fairly straightforward to build a script (using powershell, perl, python ..) to identify the files that meet your criteria, drop the fully qualified names (e.g. d:\incoming\something\filename.ext ) into a flat text file, one file name per line and then have your compression utility create an archive from that list file e.g.
If you wrap the whole thing inside the script then it's trivially easy to assign the type of archive names that you specified.
Added a Powershell example.
It's not quite a one liner, you will need to point it properly at the 7-Zip exe, add some parameter handling, some logging\error handling and it should clean up the working files but it's a pointer in the right direction.
I use a script made up from different sources..
I use 7zip and robocopy. Place both exe file in the same dir as the script.
How it works:
It deletes the previous days 'todays' folder as we want a clean slate, then robocopy scans the data folder (U:) and its set to only copy those files created or modified in the last 24hrs. It copies it to another drive/folder (F:\todays). This give you the incremental files.
7zip then compresses that folder
the next script works out the year, month, day, hours, minutes, seconds which then renames the zip file made under 7zip.
Finally the script moves the renamed zip to another folder called 'zips.
I have been using this script form many years to give me daily zip files which can quickly be opened from explorer .