So.. I've been looking around, but not really found what I need, so here goes:
I got a webcam set to upload jpg's to a folder, but to avoid my server getting overflown with files, I want to clean out all jpg's but 20 newest when I load the page that shows the pictures. If the page loads, and there are only 20 jpg's in the folder, it should do nothing.
You could do something like this:
filemtime($filename);
unlink()