forum.coppermine-gallery.net

Support => cpg1.5.x Support => cpg1.5 miscellaneous => Topic started by: D12Eminem989 on November 17, 2010, 05:22:08 pm

Title: Change file name?
Post by: D12Eminem989 on November 17, 2010, 05:22:08 pm
Is there a script or something I can change in the code to change the file name on upload so that all the picture file names are like "18gc77r4j8201hc534.jpg" or something like that?
Title: Re: Change file name?
Post by: Αndré on November 17, 2010, 09:33:40 pm
Sure. E.g. you could modify the function replace_forbidden accordingly.
Title: Re: Change file name?
Post by: D12Eminem989 on November 17, 2010, 11:27:29 pm
Can you tell me how to do that? I am no coder. :(
Title: Re: Change file name?
Post by: papukaija on November 18, 2010, 12:50:34 am
Please post a link to your gallery (http://forum.coppermine-gallery.net/index.php/topic,55415.msg270616.html#msg270616) as requested by board rules.
Title: Re: Change file name?
Post by: D12Eminem989 on November 18, 2010, 03:52:30 am
Sorry, it's a family website and thus don't want to post the link. If you can help I will pm you a link.
Title: Re: Change file name?
Post by: Αndré on November 18, 2010, 09:07:54 am
Open include/functions.inc.php, find
Code: [Select]
$filenameWithoutExtension = str_replace('.' . $extension, '', $return);and replace with something like
Code: [Select]
$filenameWithoutExtension = uniqid();
Title: Re: Change file name?
Post by: D12Eminem989 on November 18, 2010, 07:11:40 pm
That worked perfect, thank you very much!

Just one more thing if you can, how do I go about have the images I already uploaded renamed? Think you can make a script I can run to auto rename those already uploaded?
Title: Re: Change file name?
Post by: Αndré on November 18, 2010, 07:35:23 pm
They'll get renamed automatically when you try to rename that files with the edit file form. How much files do you need to rename?
Title: Re: Change file name?
Post by: D12Eminem989 on November 18, 2010, 07:51:17 pm
There are about 5,000 images I have already added that are all different names and would like those to be scrambled like the above code you gave me. The code you gave me works on new images I upload but I would like those already uploaded to be changed to.
Title: Re: Change file name?
Post by: Αndré on November 18, 2010, 08:44:51 pm
Give me some time to create the script for you.
Title: Re: Change file name?
Post by: D12Eminem989 on November 18, 2010, 08:51:02 pm
Ok, thank you very much for your support.
Title: Re: Change file name?
Post by: D12Eminem989 on November 26, 2010, 11:57:37 pm
Any progress on that script?
Title: Re: Change file name?
Post by: Αndré on November 27, 2010, 12:07:04 am
No, sorry.
Title: Re: Change file name?
Post by: D12Eminem989 on November 27, 2010, 06:47:50 am
Got an idea of when you can do this?
Title: Re: Change file name?
Post by: Αndré on November 27, 2010, 08:06:20 am
Has a low priority on my (very long) to-do list. Maybe I can provide a script which assumes that everything works as expected (= without error checks), but you should only use it if you're familiar with backup & restore or test the script thoroughly on a copy of your production gallery.
Title: Re: Change file name?
Post by: D12Eminem989 on November 30, 2010, 01:50:28 am
Yes, I am familiar with backing up and restoring as well making a test site. If you have the script, let me test it when you have a moment.
Title: Re: Change file name?
Post by: Αndré on December 08, 2010, 04:07:04 pm
Extract the attached to your gallery root and call it with a browser. It should rename your files one by one.

Use at your own risk!
Title: Re: Change file name?
Post by: D12Eminem989 on December 08, 2010, 06:07:02 pm
Thanks bud, it's working great! I appreciate it a lot. :)

Happy Holidays!