forum.coppermine-gallery.net

Support => Older/other versions => cpg1.2 Standalone Support => Topic started by: partyshaker on February 06, 2004, 04:39:17 pm

Title: Rename Picture Files
Post by: partyshaker on February 06, 2004, 04:39:17 pm
Hi,

I want to rename the picturefiles on my server.

The Problem: I includes an Mobile Service to send the pictures to an MMS-Phone. It´s works, but only if the filenames has no Spaces like

Picture1.jpg

If the name is picture 1.jpg, it does not work.

Is there any possibility to rename the pictures ?

If you want to have a look - www.PartyShaker.de
Title: Rename Picture Files
Post by: Casper on February 06, 2004, 09:24:14 pm
Hi,

The resize pics utility can change the names, within set parameters.  At the moment, it is set to remove '_', and replace it with a space, but a simple mod to the util.php should reverse the process, so you can replace spaces with something else.

I'll have a look at it for you.
Title: Rename Picture Files
Post by: Casper on February 06, 2004, 09:45:07 pm
Hi again,

yes, it works, and is easy.  I have altered it to leave the jpg extension, and to remove spaces

Open util.php, find this code;

Code: [Select]
// REMOVE .JPG AND REPLACE _ WITH [ ]
                $filename = substr($filename, 0, -4);
                $newtitle = str_replace("_", " ", $filename);


Change it to this;

Code: [Select]
// REMOVE .JPG AND REPLACE _ WITH [ ]
                //$filename = substr($filename, 0, -4);
                $newtitle = str_replace(" ", "", $filename);


Now open lang/your_lang.php, and find this code (note, the words after => will be in your language);

Code: [Select]
'filename_remove' => 'Remove the .jpg ending and replace _ (underscore) with spaces',

Change it to;

Code: [Select]
'filename_remove' => 'Remove spaces'',
Title: Rename Picture Files
Post by: Joachim Müller on February 06, 2004, 10:58:00 pm
...and to avoid such stuff in the future, never upload files to your server that contain spaces or other problematic characters to your webserver again. If you want to make sure you don't have spaces in filenames in the future, check "Characters forbidden in filenames" in coppermine config and add a list of characters that shouldn't be in filenames in the first place (in fact, there should only be "regular" letters [a-z], numbers [0-9] minus [-] and underscore [_] in any file you upload to a webserver).

GauGau
Title: Re: Rename Picture Files
Post by: Pasha on November 20, 2004, 10:05:38 pm
I didn't notice the " ' " character in the folder name while using "Batch Upload". I've uploded those files from my Windows machine and didn't correct all the folder names.
So I have a " ... Pasha's visit ..." folder there. Attempt to delete a picture from this album now gives an MySQL error message:

While executing query "DELETE FROM cpg132_exif WHERE filename='albums/massupload/Bloomington/2002/Pasha's Visit, Feb 18/DVC00412.JPG' LIMIT 1" on 0

mySQL error: You have an error in your SQL syntax.  Check the manual that corresponds to your MySQL server version for the right syntax to use near 's Visit, Feb 18/DVC00412.JPG' LIMIT 1' at line 1

Is there any graceful way to rename the directory along with those links to it in the database? I realise that I made a mistake, and I will certainly try not to repeat it again.

Thank you very much,
Pasha.
Title: Re: Rename Picture Files
Post by: Pasha on November 21, 2004, 01:05:37 am
The solution I suggested (and implemented, since I sometimes get a little impatient) is the following:

Rename the folder, so that it no longer has "bad" characters.
Go to your database for coppermine photo album. Edit table cpg132_pictures, the "filepath" field in particular, so it pointsto the right place.

Not very graceful, but still a solution.

Good luck,  and thank you very much for all your hard work and support,
Pasha Anaschenko.
Title: Re: Rename Picture Files
Post by: Joachim Müller on November 21, 2004, 07:04:00 am
this issue is related to usage of the old cpg1.2 version, afaik it has been ironed out in cpg1.3.
Upgrading to the most recent stable version (cpg1.3.2) is strongly recommended.

Joachim
Title: Re: Rename Picture Files
Post by: Pasha on November 21, 2004, 05:30:36 pm
I am using cpg 1.3.2, which means this little  problem is still there.

-Pasha.

Title: Re: Rename Picture Files
Post by: Joachim Müller on November 22, 2004, 09:15:03 am
check your "Characters forbidden in filenames" settings in coppermine config (post them here), please.

Joachim
Title: Re: Rename Picture Files
Post by: Pasha on November 22, 2004, 05:57:14 pm
I kept the default setting, since I was not quite sure what that thing was and how it works.
Later (after the "accident") , I think, I added "&" at the end.

Here is what it is now:         $/\\:*?"'<>|`&

Pasha.