Archive for November, 2010

Zipping files by type and date range from OSX command line

I needed to zip some flash files that had changed in the last 3 days across a set of subdirectories. This is the one liner that I came up with. This is mainly for future me as this comes up all the time.

find /in/directory/ -mtime -3 | grep fla | xargs zip foundFiles

find /in/directory/ -mtime -3 finds all of the files changed in the last 3 days. -mtime has a nice set of options.

grep fla finds the flash files. Regular expressions can get really complicated. This one isn’t, so it’s possible that it might match unintended files. Run up to this part to see if it will grab your files of interest so you don’t zip a bunch of unnecessary files.

xargs zip foundFiles xargs is a handy utility that takes arguments from a pipe and hands them to another program – in this case zip.

After you run this you should have a zip in your home directory named foundFiles.zip or whatever you chose to call the files.

Leave a Comment