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

0 Members and 1 Guest are viewing this topic.

Offline Jáchym

  • Meteotemplate Developer
  • Forecaster
  • *****
  • Posts: 8534
    • 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: 381
    • 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: 8534
    • 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: 381
    • 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

  • Senior Contributor
  • ****
  • Posts: 216
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: 381
    • 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

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

Regards

Online PaulMy

  • Forecaster
  • *****
  • Posts: 3645
    • 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: 381
    • 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

 

anything