Re: Lots of files - how to select newest 10K files



CptDondo <yan@xxxxxxxxxxxxxxxx> writes:

On Fri, 08 Feb 2008 07:58:58 -0700, Douglas Mayne wrote:
This sounds a bit like a contrived homework-style problem.
Your problem seems some arbitrary collection of files until 10,000 files
have been selected. I can see that there is a case where some new files
will never be selected. For example, if more that 10,000 files are
created on the interval. That makes this look like a contrived
homework-style problem. I suppose that the contents of the four reports
presented above could be tweaked until the requirement is met and that
satisfy your selection criteria.

Well, it's not homework but it is a bit contrived.

Visit http://www.seiner.com and look at the lizardcam and the snakecam.
The crittercams run at 12FPS but motion only saves the frames when it
detects motion. The result is that every I have a directory with
thousands of time-stamped jpg images.

I have a script that runs every hour, which creates a flash video from
the last 24 hours' worth of images, and deletes anything older than that.

In a typical 24 hour period, the lizard is active for about an hour,
which, with my ~ 4:1 speedup, creates about 10-15 minutes of video.
Great.

The snake is only active a few minutes a day; after feeding it may not
move at all for a day or two. So the videos are uniformly boring and
short. Then, when she gets hungry, she will be very active and create a
few minutes of video whenever she hunts.

The snakecam is the problem. I want to end up with at least 10-15
minutes of snake video, which means that I have to keep about 10,000
frames even if it means keeping the previous day's activity. But when
she's 'hunting' she can move a lot and easily exceed 10K frames in a day.

Thus my problem. I want to have enough frames to create a movie of about
10 minutes even if it means using yesterday's footage, but if she moves
enough to create 20K frames in a 24 period I want to show that too.


Ah, finally you explain your problem
ls -t .|awk 'BEGIN{i=0} {file[i]=$0;i++} END{if(i>10000) for (j=10000;j<i;j++) print file[j]}'|xargs rm
might work.
This assumes that all of the snake files are in a single directory without
any others. This command erases all the oldest files greater than 10000 the
10000th.
ls -t .
lists all of the files in the current directory in temporal order, newest
first. The awk command numbers the files, and then if there are more than
10000 of them erases those that are oldest. However you want more, you want
to keep all of todays if there are more than 10000. So, do something like
export NTODAY=`find . -mtime -1 |wc -w`
if [ $NTODAY -gt 10000 ]; then
find . -mtime +1|xargs rm
else
ls -t .|awk 'BEGIN{i=0} {file[i]=$0;i++} END{if(i>10000) for (j=10000;j<i;j++) printf( "%s ", file[j])}'|xargs rm
fi

That will leave you with either all of todays (ie the past 24 hours), or up to 10000 whichever is
greater. and erase all the rest.

Note that I have not particularly tested this so use at your own risk.



.



Relevant Pages

  • Re: Can I play only specified frames of a movie in ppt
    ... you can do this if you insert your movie as an object - you'll need to ... set the Start Selection and End Selection points though in Media Player - ... names Media Object or Video Object any more - however, ... on other occassions we wish to only show frames 2003 to 2545 etc. ...
    (microsoft.public.powerpoint)
  • Re: Lots of files - how to select newest 10K files
    ... satisfy your selection criteria. ... The crittercams run at 12FPS but motion only saves the frames when it ... I have a script that runs every hour, which creates a flash video from ... minutes of snake video, which means that I have to keep about 10,000 ...
    (comp.os.linux.misc)
  • Re: delete frames in word doc based on content?
    ... It's always better to work with the .Range object when you can rather than ... Selection object as with the former, the screen does not have to be ... > I tried your second suggestion which deleted the ... contents of the frames but not the frames. ...
    (microsoft.public.word.vba.general)
  • Re: Automatic Component Video Switcher
    ... input has signals it takes the "highest priority", ... if input is composite video then output for that source will also be ... if input is component video then output for that source ... Additionally, though the PH61150 does not support selection via a remote, it ...
    (alt.tv.tech.hdtv)
  • Re: Everything but audio/video
    ... when you run the Wizard do you see yourself in the video ... > except for the audio and video. ... > Joel - you seem to help everyone in this newsgroup. ...
    (microsoft.public.windowsxp.messenger)

Loading