Advanced search  

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]

Pages: [1]   Go Down

Author Topic: Change file name?  (Read 4248 times)

0 Members and 1 Guest are viewing this topic.

D12Eminem989

  • Coppermine newbie
  • Offline Offline
  • Posts: 16
Change file name?
« 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?
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15765
Re: Change file name?
« Reply #1 on: November 17, 2010, 09:33:40 pm »

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

D12Eminem989

  • Coppermine newbie
  • Offline Offline
  • Posts: 16
Re: Change file name?
« Reply #2 on: November 17, 2010, 11:27:29 pm »

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

papukaija

  • Contributor
  • Coppermine frequent poster
  • ***
  • Country: 00
  • Offline Offline
  • Posts: 333
Re: Change file name?
« Reply #3 on: November 18, 2010, 12:50:34 am »

Please post a link to your gallery as requested by board rules.
Logged

D12Eminem989

  • Coppermine newbie
  • Offline Offline
  • Posts: 16
Re: Change file name?
« Reply #4 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.
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15765
Re: Change file name?
« Reply #5 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();
Logged

D12Eminem989

  • Coppermine newbie
  • Offline Offline
  • Posts: 16
Re: Change file name?
« Reply #6 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?
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15765
Re: Change file name?
« Reply #7 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?
Logged

D12Eminem989

  • Coppermine newbie
  • Offline Offline
  • Posts: 16
Re: Change file name?
« Reply #8 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.
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15765
Re: Change file name?
« Reply #9 on: November 18, 2010, 08:44:51 pm »

Give me some time to create the script for you.
Logged

D12Eminem989

  • Coppermine newbie
  • Offline Offline
  • Posts: 16
Re: Change file name?
« Reply #10 on: November 18, 2010, 08:51:02 pm »

Ok, thank you very much for your support.
Logged

D12Eminem989

  • Coppermine newbie
  • Offline Offline
  • Posts: 16
Re: Change file name?
« Reply #11 on: November 26, 2010, 11:57:37 pm »

Any progress on that script?
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15765
Re: Change file name?
« Reply #12 on: November 27, 2010, 12:07:04 am »

No, sorry.
Logged

D12Eminem989

  • Coppermine newbie
  • Offline Offline
  • Posts: 16
Re: Change file name?
« Reply #13 on: November 27, 2010, 06:47:50 am »

Got an idea of when you can do this?
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15765
Re: Change file name?
« Reply #14 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.
Logged

D12Eminem989

  • Coppermine newbie
  • Offline Offline
  • Posts: 16
Re: Change file name?
« Reply #15 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.
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15765
Re: Change file name?
« Reply #16 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!
Logged

D12Eminem989

  • Coppermine newbie
  • Offline Offline
  • Posts: 16
Re: Change file name?
« Reply #17 on: December 08, 2010, 06:07:02 pm »

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

Happy Holidays!
Logged
Pages: [1]   Go Up
 

Page created in 0.019 seconds with 19 queries.