Author Topic: Image Rename Script Help **Solved**  (Read 4500 times)

0 Members and 1 Guest are viewing this topic.

Offline Jáchym

  • Meteotemplate Developer
  • Forecaster
  • *****
  • Posts: 8605
    • Meteotemplate
Re: Image Rename Script Help
« Reply #25 on: October 15, 2017, 05:50:39 AM »
That sort error is because the while loop is not satisfied by any file in that folder, the array is not created and it then doesn´t know what to sort

Offline Ian.

  • Forecaster
  • *****
  • Posts: 459
    • Chatteris Weather
Re: Image Rename Script Help
« Reply #26 on: October 15, 2017, 08:06:38 AM »
Hi Jachym,

Thanks for pitching in, is it that the script deletes the file before it has been renamed due to an error?

The upload folder does have a file in it, and after running this is deleted.

No newname image is created.

Ian
CWOP - DW3371
PWS - ICAMBRID16
https://www.chatteris.biz

Offline Jáchym

  • Meteotemplate Developer
  • Forecaster
  • *****
  • Posts: 8605
    • Meteotemplate
Re: Image Rename Script Help
« Reply #27 on: October 15, 2017, 08:41:22 AM »
I am not familiar with those functions, I would use the "glob" function for scanning the dir content

Offline Ian.

  • Forecaster
  • *****
  • Posts: 459
    • Chatteris Weather
Re: Image Rename Script Help
« Reply #28 on: October 15, 2017, 09:09:15 AM »
No probs, I'll ask on the forum if anyone will share a working script in case the one I'm using is flawed.

Cheers

Ian

**Solved** the upper case JPG threw the script, all working now, thanks a million to all.
« Last Edit: October 15, 2017, 11:34:32 AM by Ian. »
CWOP - DW3371
PWS - ICAMBRID16
https://www.chatteris.biz

Offline droiddk

  • Forecaster
  • *****
  • Posts: 334
Re: Image Rename Script Help **Solved**
« Reply #29 on: October 15, 2017, 02:29:14 PM »
Hi Ian

Marked as solved?

And I agree with Jáchym and will use glob.

This simple script will find jpg's in the folder where the script is and save the latest as image.jpg, can be used with a cron-job.

<?php

if ($images = glob("*.jpg") ) {

   rsort($images);

   $img = $images[0];

   $newfile = 'image.jpg';

   copy($img, $newfile);

}

?>

Kind Regards
Droid

Offline Ian.

  • Forecaster
  • *****
  • Posts: 459
    • Chatteris Weather
Re: Image Rename Script Help **Solved**
« Reply #30 on: October 15, 2017, 02:38:48 PM »
Hi Droid,

Yep all sorted, the script you shared was incredibly useful and I will be using that for another task, the original renaming script is up and running, so I have had a good day...well that was until I asked GoDaddy to migrate my website to a European server and it broke the SSL certificate whichj means I can't send data, so well pi**ed off.
CWOP - DW3371
PWS - ICAMBRID16
https://www.chatteris.biz

Offline droiddk

  • Forecaster
  • *****
  • Posts: 334
Re: Image Rename Script Help **Solved**
« Reply #31 on: October 15, 2017, 02:51:56 PM »
Glad it works (the script)  :grin:

Regards

Offline PaulMy

  • Forecaster
  • *****
  • Posts: 5509
    • KomokaWeather
Re: Image Rename Script Help **Solved**
« Reply #32 on: October 15, 2017, 02:54:55 PM »
Quote
the original renaming script is up and running, so I have had a good day...well that was until
What changes did you need to make to the script Ian?

Enjoy,
Paul

Offline Ian.

  • Forecaster
  • *****
  • Posts: 459
    • Chatteris Weather
Re: Image Rename Script Help **Solved**
« Reply #33 on: October 15, 2017, 03:00:23 PM »
Hi Paul,

I compared the original script with the one I was using and the only difference was that the timezone was enabled and I had .JPG rather than .jpg set in one place.

Using your description really helped as I reconstructed it and worked through until it worked.

So many thanks

Ian
CWOP - DW3371
PWS - ICAMBRID16
https://www.chatteris.biz

Offline WessexWeather

  • Senior Member
  • **
  • Posts: 83
    • WessexWeather
Re: Image Rename Script Help **Solved**
« Reply #34 on: June 22, 2020, 05:58:07 PM »
Hi Ian

Marked as solved?

And I agree with Jáchym and will use glob.

This simple script will find jpg's in the folder where the script is and save the latest as image.jpg, can be used with a cron-job.

<?php

if ($images = glob("*.jpg") ) {

   rsort($images);

   $img = $images[0];

   $newfile = 'image.jpg';

   copy($img, $newfile);

}

?>

Kind Regards
Droid

Hi Droid,

Reviving an old thread here... your script works perfectly with filenames. Can it be adapted to sort by timestamp, taking and renaming the most recent image regardless of filename?
Cheers,

Simon (WessexWeather)


Offline LU9DKL

  • Member
  • *
  • Posts: 2
    • Clima Saladillo
Re: Image Rename Script Help **Solved**
« Reply #35 on: September 28, 2020, 10:25:58 AM »
Hello, can anyone help me?

I have a dvr that uploads ftp every 60 seconds a photo to

climasaladillo.com:/public_html/192.168.0.150/2020-09-26/XVR_ch4_20200926102653_T.jpg

I need to delete the old photo every time I upload a new one and rename the new one to image.jpg


Offline PaulMy

  • Forecaster
  • *****
  • Posts: 5509
    • KomokaWeather
Re: Image Rename Script Help **Solved**
« Reply #36 on: September 28, 2020, 11:36:47 AM »
Have you tried the scripts mentioned above or https://www.wxforum.net/index.php?topic=32044.msg322649#msg322649  and do they not work?


Enjoy,
Paul



Offline LU9DKL

  • Member
  • *
  • Posts: 2
    • Clima Saladillo
Re: Image Rename Script Help **Solved**
« Reply #37 on: September 29, 2020, 08:59:15 AM »


Hi Paul, good morning, could you help me configure the script you quoted? I'm new to this   :oops:

P.S. My dvr is dahua does this script work the same?

Offline PaulMy

  • Forecaster
  • *****
  • Posts: 5509
    • KomokaWeather
Re: Image Rename Script Help **Solved**
« Reply #38 on: September 29, 2020, 11:17:49 AM »
Hi,
My Hikvision failed a few years ago so it has been a long time since I looked at this, and my PHP coding skill is next to nothing.  Also, the code in the script is old and the script no longer works komokaweather.com/pictures/hv/hik.php and see the same for the other links here.  Likely someone has created an alternate way to do the rename.  Unfortunately the heading of this thread says **Resolved**  and that may stop people from looking at it.


I now have a newer camera and use the Sebec IPTimelapse program that uses a fixed name for file uploading.


Enjoy,
Paul
 

 

anything