ZIP all files older than...

G

Guest

One of our programs generates many temporary files of various types,
specifically .tmp, .log and .p1. These can be removed past a certain date,
but I'd prefer to simply zip them up.

I've looked at a few zip utilities, but I can't find one with a command like
this. I assume I can do this from a command line, but I'm not sure how.

Basically I'd like to have a script that finds all files more than one month
older than (today) and adds them to a file called "archive_(today).zip".

Can someone help me do this?

Maury
 
G

Guest

Howdy..
This may not be the easiest way to do it.. But you could schedule a batch
file every month which removed the archived bit from the relevant files then
redirect a 'dir' command to a txt file which lists all files without the
archive bit set and use a command line zip utility like http://www.7-zip.org/
which allows you to select a text file to list all files you want zipped.

Something like..

rem list all files without the archive bit set.
dir /a-a-d /b > compressme.txt

rem (get ready for next month)
attrib -a *.*

7z a -tzip archive.zip @compressme.txt

rem (delete files you've just compressed)
del *.* /a-a

This may not work perfectly.. But it might give you an idea on a better
solution.

Regards
Paul Mckenna
 
J

Jack

Assuming the files are in the same folder (or just a few), why not simply
use Explore to sort by date modified, select, right-click, and Send
To/Compressed Folder?

Jack


message One of our programs generates many temporary files of various types,
specifically .tmp, .log and .p1. These can be removed past a certain date,
but I'd prefer to simply zip them up.

I've looked at a few zip utilities, but I can't find one with a command like
this. I assume I can do this from a command line, but I'm not sure how.

Basically I'd like to have a script that finds all files more than one month
older than (today) and adds them to a file called "archive_(today).zip".

Can someone help me do this?

Maury
 
G

Guest

Paul Mckenna said:
Something like..

rem list all files without the archive bit set.
dir /a-a-d /b > compressme.txt

rem (get ready for next month)
attrib -a *.*

7z a -tzip archive.zip @compressme.txt

rem (delete files you've just compressed)
del *.* /a-a

Thanks Paul, I'll try this!

Maury
 
G

Guest

Paul Mckenna said:
rem list all files without the archive bit set.
dir /a-a-d /b > compressme.txt

Out of curiosity, exactly what is this bit? Who sets it and when?

When I run this on my machine it returns nothing at all. I assume that's
because nothing in my directory has this bit set. Your script finds all of
them, and then sets everything to have this bit set, so that next month I
find the new stuff. I'm just worried that someone else might come in and
set/clear the bit on us.

And any suggestions on how to prime the pump? That is, is there a way to set
this bit on for all the "older" files?

Maury
 
G

Guest

Jack said:
Assuming the files are in the same folder (or just a few), why not simply
use Explore to sort by date modified, select, right-click, and Send
To/Compressed Folder?

Some time you should try this... put 3000 files in a folder and then try
what you just said. Note that to see the problem, 2800 of the files should
"match".

Maury
 
D

David Candy

Attribute is set by the file system when you create or save a file. Backup programs clear it.

Attrib can batch change it.

attrib +a c:\*.* /s
 
T

Tim Slattery

Maury Markowitz said:
Out of curiosity, exactly what is this bit? Who sets it and when?

It's one of the four basic property bits that all files have, in all
file systems starting with FAT16. The other three are system, hidden,
and read-only.

When a new file is created or an existing one is updated, the OS sets
the archive bit. The idea is that some backup software will come
along, see that the bit is set, and react by backing up the file and
clearing the bit. If you're not running backup software, the tendency
is for all your files to have their archive bit set.

In WinXP with NTFS, select a file in Windows Explorer, right-click it
and choose "Properties". In the bottom of the window that appears,
you'll see check boxes reflecting the "hidden" and "read-only" bits.
Click the "Advanced" button, and you'll see another checkbox labeled
"File is ready for archiving". That's the archive bit.

The GUI won't show you the "System" bit. You can use the command-line
"attrib" utility to see it, but you really shouldn't mess with system
files.
When I run this on my machine it returns nothing at all. I assume that's
because nothing in my directory has this bit set.

The command should print a list of file without the archive bit set.
As I said above, it's entirely likely that all the files in your
directory have the archive bit set.
 
G

Guest

David Candy said:
What's wrong with
pkzip -a -t 26/2/05 c:\myzip.zip *.*

I take that back:

1) the first hit for pkzip downloads on Google tried to install spyware
2) there is no freeware version

Maury
 
D

David Candy

www.pkware.com. Version 2.50 for Dos is the best as it works on nearly all platforms. They invented the zip file format. It free for home use. It's free for one copy in an organisation. It's based on honour.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top