How to schedule specific files archiving ( 7-zip ) on Windows

1

I have directory with *.wek files. Each day some application adds there about 10 new files. I want to archive only those 10 new files at certain time of the day. I've read about 7-zip mechanism but i haven't found how do i filter files for dates so only this day files will be archived.

Any help? thanks.

eugeneK

Posted 2010-08-02T06:43:52.667

Reputation: 131

do you want to put these 10 new files to a new archive or do you want to update an existing archive so at the end of the operation the existing archive contains 10 new files PLUS the old content? – akira – 2010-08-02T08:13:20.667

@akira, i want to put new files in archive and delete previous set. ie. delete file.7z, add only new files – eugeneK – 2010-08-02T08:24:38.013

Answers

1

I'm confused about what you're trying to do.

Option 1: Why not just zip the entire directory? The zip process doesn't care if there were 10 files yesterday, and 10 new ones that it added today.

Option 2: Create a batch file that deletes yesterday's zip file, then creates a new one for today.

Option 3: Create a batch file that archives the *.wek files one at a time. If the archived file already exists, don't do anything to that file.

Code for Option 3:

:: This file will backup *.wek files into *.wek.zip

:: i.e., abc.wek gets zipped into abc.wek.zip

:: If the matching zip file already exists, the original file does not get backed up.

:: i.e., if cde.wek.zip already exists, then cde.wek does not get backed up

:: IMPORTANT:

:: change \path\to\files (below) to the correct path to your files that need to be backed up

:: change \path\to\archives (below, twice) to the correct location of your backup folder

:: change c:\tools\7zip\7za.exe (below) to the correct path to the 7-zip command-line tool ::

:: make sure we're on the C drive

C:

:: change to our data directory

cd \path\to\files

:: create the backups

for %%k in (*.wek) do if not exist "c:\path\to\archives\%%k.zip" c:\tools\7zip\7za.exe a "c:\path\to\archives\%%k.zip" "%%k"

Tom

Posted 2010-08-02T06:43:52.667

Reputation: 1 321