Find All Files Created in Specified Time Interval

This is totally dumb, but I just can’t figure out how to do this “in place”. I want to find all the files of a given type in a certain directory, and it’s subdirectories that were created in a given time interval. So for example, find all the jpg images that were created in 2006.

I can do it in 3 steps (4 if you count cleanup of temp files):

touch --date="01/01/2006" /tmp/t.06$$
touch --date="01/01/2007" /tmp/t.07$$
find ~/scans -newer /tmp/t.06$$ ! -newer /tmp/t.07$$ -iname "*.jpg"
rm -f /tmp/t.0*$$

It works, but it seems to be way to much work for something this silly. There really should be a way to do this in one step. What am I missing here?

Update 02/23/2007 12:55:23 PM

I created a bash script of this for convenience. It takes in 4 parameters: the path to be searched, the start date, the end date, and file type.

#!/bin/bash
touch --date="$2" /tmp/t.01$$
touch --date="$3" /tmp/t.02$$
find $1 -newer /tmp/t.01$$ ! -newer /tmp/t.02$$ -iname "*.$4"
rm -f /tmp/t.0?$$

Sample usage would be:

findfrom ~/scans 01/01/2006 01/01/2007 jpg

That’s of cours assuming that you call this script findfrom like I did.

Related Posts:

  • MySQL: find week start/end given week number
  • File Transfer Problem
  • Call of Duty Multiplayer Crashing on Startup
  • Outlook 2003 Attachment Dialog Doesn’t Show Zip Files
  • Easy Way to Create Simple Linux Packages
  • Convert PS and EPS images to JPEG
  • Burning .RMVB files to VCD/DVD
  • Linux: Quick and Dirty Way to Take Screenshots
  • Unknown Error 0×80040119
  • Run PNGOUT on all PNG Files in a Folder

  • 2 Responses to “Find All Files Created in Specified Time Interval”

    1. Gravatar Craig Betts UNITED STATES Says: Reply to this comment

      That is exactly how I would do it, except it would be on one command line with each of your lines seperated by a semicolon. If you want simplicity, write a script that creates and removes the files for you.

      Posted using Mozilla Firefox Mozilla Firefox 2.0.0.1 on Mac OS Mac OS X
    2. Gravatar Luke UNITED STATES Says: Reply to this comment

      Ok, so it’s not me. It’s just find being awkward and silly with it’s non-standard syntax.

      For a moment there I thought maybe I’m just being dense here. P

      Posted using Mozilla Firefox Mozilla Firefox 2.0 on Ubuntu Linux Ubuntu Linux

    Leave a Reply

    XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <pre lang=""> <em> <i> <strike> <strong>

    [Quote selected]