Thursday, April 17, 2008

File size, file count, file age - batch util

I wanted to know each of this:
  • If a filesize (eg. the newest/latest one in a directory) is above or below a certain threshold.
  • If a number of files in a dir is equal, above or below a certain limit.
  • If the age of a file (eg. the newest/latest one), is above or below a certain age in seconds.

I turned to the batch search/overview sites and looked for inspiration, my findings was

  • FileSizeComp is an elegant example in batch, but requires you know the filename.
  • GetDirStats returns number of files, elegantly using dirlist from compact.
  • I did not find a batch way to get mtime of a file.

So: two problems: I would need a way to find "the latest file" and then pipe that to one of the batch scripts, and I didnt find a ressource kit tool or batch way to get mtime from a file.

So: I made a simple perl script that can handle all of the above. And it also works cross platform.

There was someone who did an mtime (file age) check script in vbscript, i did not use it though.

1 comment:

Anonymous said...

Hello. This post is likeable, and your blog is very interesting, congratulations :-). I will add in my blogroll =). If possible gives a last there on my blog, it is about the Notebook, I hope you enjoy. The address is http://notebooks-brasil.blogspot.com. A hug.