Current location: Hot Scripts Forums » General Community » Script Requests » rename newest image, delete oldest image for webcam ftp upload


rename newest image, delete oldest image for webcam ftp upload

Reply
  #1 (permalink)  
Old 05-08-09, 05:20 AM
corinb corinb is offline
New Member
 
Join Date: May 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
rename newest image, delete oldest image for webcam ftp upload

Hi

I have a webcam uploading images successfully via ftp to a folder on a website, however these images are uploaded with different file names each time depending on the time and date of the upload in the format P_2009-05-07_19-07-13_542.jpg resulting in an ever increasing number of images.

I want to link directly to the newest image in the format mysite.com/webcam/image.jpg

So is it possible to have a script which deletes the oldest entries and renames the latest picture to image.jpg ?

I can then set a CRON job to call this script periodically.

Thanks for the help

c
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 04-19-11, 02:43 PM
swiftarf swiftarf is offline
New Member
 
Join Date: Apr 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Renaming image files

My ip cam uploads timestamped images. I only want the latest so I rename all the images in a directory to webcam.jpg. I call it every hour with a cron job -only the first image uploaded after the most recent cron is left. Although this is crude, it works

If you want anything more elaborate you'll have to read the filenames into an array and reverse the array to get the latest file & rename that.

<?php
if ($handle = opendir('.')) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != ".." && preg_match("/jpg$/",$file) && $file !="webcam.jpg") {
rename($file, 'webcam.jpg');
}
}
closedir($handle);
}
?>

Hope this helps
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
div css theighost CSS 11 09-14-08 03:30 AM
User Image Upload Script Phrozen44 Script Requests 12 07-16-08 01:15 AM
Image Upload Perms automatically set to 600 progress Perl 2 10-05-05 01:19 PM
ASP upload prob minority ASP 1 06-27-05 09:35 AM
Image upload and if / else mdhall PHP 4 11-14-04 04:12 PM


All times are GMT -5. The time now is 05:51 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.