Change file name? Change file name?
 

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Main Menu

Change file name?

Started by D12Eminem989, November 17, 2010, 05:22:08 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

D12Eminem989

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?

Αndré

Sure. E.g. you could modify the function replace_forbidden accordingly.

D12Eminem989

Can you tell me how to do that? I am no coder. :(

papukaija


D12Eminem989

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.

Αndré

Open include/functions.inc.php, find
$filenameWithoutExtension = str_replace('.' . $extension, '', $return);
and replace with something like
$filenameWithoutExtension = uniqid();

D12Eminem989

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?

Αndré

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?

D12Eminem989

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.

Αndré

Give me some time to create the script for you.

D12Eminem989

Ok, thank you very much for your support.

D12Eminem989

Any progress on that script?

Αndré


D12Eminem989

Got an idea of when you can do this?

Αndré

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.

D12Eminem989

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.

Αndré

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!

D12Eminem989

Thanks bud, it's working great! I appreciate it a lot. :)

Happy Holidays!