Archiving by Time

Hi all. I am trying to set up archiving of directories, such that I keep every directory made in the past week, but just one directory per week beyond that. Using the find command, I can easily delete everything more than one week old, but can not figure out how to save one.

Each directory contains a single zip file. I'd prefer to keep the one with the largest zip file, but this is not necessary. If someone can tell me how I can keep just one directory, regardless of criteria, I would be greatly appreciative.

I realize that this could probably be done by hand, but a zip file and directory is created ~every 30 minutes, so it would be rather tedious.

Thanks for any help you can provide.

EDIT: This archiving is currently done (deleting everything more than a week old) in a shell script that is called by the program. This script creates and moves the zip file from a bunch of jpg's. Hence, I figured this was the correct sub-forum. If not, let me know and I will be glad to move it.

So is this solved or still open?

If it is still open - why not do a find to get largest of them, safe it first, and then delete all of them (if I got it right)?

It is still open. I did not see an option among the man page for "find" to get the largest file. Which option is it?

Sorry, might be misleading, as find can only show files compared to some size, what might give you still too many files, instead of 1 for the largest. Here is a bit lengthy explanation, how you could handle this and implement in the script you already have:

root@isau02:/data/tmp/testfeld> ll
insgesamt 36
drwxr-xr-x 2 isau users 4096 2008-07-18 13:59 .
drwxr-xr-x 7 isau users 4096 2008-07-09 14:36 ..
-rwx------ 1 root root   197 2008-07-08 10:00 array.ksh
-rw-r--r-- 1 root root    98 2008-07-17 14:31 infile
-rwx------ 1 root root   207 2008-07-04 10:10 input.ksh
-rwx------ 1 root root   328 2008-07-08 09:21 loop.ksh
-rwx------ 1 root root    27 2008-07-18 13:59 mach.ksh
-rw-r--r-- 1 root root   845 2008-07-08 07:58 NMEA.txt
-rw-r--r-- 1 root root     0 2008-07-18 13:55 temp2.txt
-rwx------ 1 root root   174 2008-06-27 13:25 weekend_is_close.ksh
root@isau02:/data/tmp/testfeld> find . -type f -exec ls -la {} \;| awk '{print $5,$NF}'
207 ./input.ksh
328 ./loop.ksh
845 ./NMEA.txt
98 ./infile
197 ./array.ksh
27 ./mach.ksh
0 ./temp2.txt
174 ./weekend_is_close.ksh
root@isau02:/data/tmp/testfeld> find . -type f -exec ls -la {} \;| awk '{print $5,$NF}'| sort -k 1,1n
0 ./temp2.txt
27 ./mach.ksh
98 ./infile
174 ./weekend_is_close.ksh
197 ./array.ksh
207 ./input.ksh
328 ./loop.ksh
845 ./NMEA.txt
root@isau02:/data/tmp/testfeld> find . -type f -exec ls -la {} \;| awk '{print $5,$NF}'| sort -k 1,1n| tail -1| awk '{print $2}'
./NMEA.txt

That is quite helpful, but seems to be missing the final step. Once I pick out that file, how can I execute any other command on it? I am thinking I just want to 'touch' that file and make the date far enough in the past that the script will cease caring about it. Thanks again.