forum.coppermine-gallery.net
Support => cpg1.5.x Support => cpg1.5 miscellaneous => Topic started 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?
-
Sure. E.g. you could modify the function replace_forbidden accordingly.
-
Can you tell me how to do that? I am no coder. :(
-
Please post a link to your gallery (http://forum.coppermine-gallery.net/index.php/topic,55415.msg270616.html#msg270616) as requested by board rules.
-
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.
-
Open include/functions.inc.php, find
$filenameWithoutExtension = str_replace('.' . $extension, '', $return);
and replace with something like
$filenameWithoutExtension = uniqid();
-
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?
-
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?
-
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.
-
Give me some time to create the script for you.
-
Ok, thank you very much for your support.
-
Any progress on that script?
-
No, sorry.
-
Got an idea of when you can do this?
-
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.
-
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.
-
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!
-
Thanks bud, it's working great! I appreciate it a lot. :)
Happy Holidays!