delete photos php script

Chat about anything... (as long as it is a sensible debate :-) )
Post Reply
proger
Observer
Observer
Posts: 35
Joined: Tue Jan 16, 2018 4:52 pm
Location: Norway
Station model: davis vantage vue
Software: Meteobridge
Contact:

delete photos php script

Post by proger » Sun Mar 11, 2018 9:46 pm

I am trying to delete photos from /plugin/webcam/ folder older than x days.

This script is doing that.
But what I am wondering if there is a way of getting the script to delete the thumbnails as well in the subfolder
here is the script I found online

<?php

/** define the directory **/
$dir = "images/";
/*** cycle through all files in the directory ***/
foreach (glob($dir."*.jpg") as $file) {
/*** if file is 24 hours (259200 seconds) old then delete it ***/
if(time() - filectime($file) > 259200){
unlink($file);

thanks in advance
Image

User avatar
Fraggboy
Forecaster
Forecaster
Posts: 193
Joined: Wed Sep 27, 2017 2:45 pm
Location: Sunny California
Station model: Bloomsky II + Storm
Software: Bloomsky
Contact:

Re: delete photos php script

Post by Fraggboy » Mon Mar 12, 2018 8:15 pm

I just execute 1 script for 3 different locations in a cron job (I execute the script every 7 days). This script removes all files that is older than 5 days.

Code: Select all

find /www/template/plugins/bloomSky/images* -mtime +5 -exec rm {} \;
find /www/template/plugins/bloomSky/images/thumbnails* -mtime +5 -exec rm {} \;
find /www/template/plugins/bloomSky/videos* -mtime +5 -exec rm {} \;
I'm using this for my Bloomsky image, video and thumbnail folders (Different application, but should work for the webcam folder)
Image

Post Reply