Using the GUI this task is trivial (Sort by list view, click on the Date heading to order by date, select the relevant folders then right click and Compress.)
Using the command line to achieve the same results is a trifle harder. Here’s the command line I came up with:
tar zcvf ArchiveName.tar.gz `find * -maxdepth 0 -mtime +893`
The find command in the gets executed first and returns the folders and files in the CURRENT directory that haven’t been modified since the number of days specified by the number in the find command.
Tar then does it’s usual job and compresses it.
If you’re wanting to remove directories using a similar command just substitute in the rm command instead of the tar command.
To find the number of days to a date in the past I used this website here but I’m sure there’s something you can do with the date command that will give you a similar output!
One response to “How to archive folders older than a certain date in Linux / Ubuntu”
When are you going to move away from these Linux Moo Moo guides and tell me and my wife Bettina how to make a quite splendid casserole?
I have heard only good things about your casserole making, lovely use of vegetables, carrots, turnip, clove of garlic… jam? Only kidding, no carrots right?
Anyway, I’m off to practice my speed boating at lake with Arnold.
Yours, Ted Peg.
Editor-in-Chief, Horse Weekly