How to move/split lots of photos from one single album to multiple albums How to move/split lots of photos from one single album to multiple albums
 

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Main Menu

How to move/split lots of photos from one single album to multiple albums

Started by xiaolu, December 03, 2016, 11:23:43 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

xiaolu

Hello everyone! I am new to Coppermine Gallery. Just installed it at:

http://www.xiaolujin.com/gallery/index.php

I am using this gallery to show photos on my phpBB forum, by the way.

I realized I kind of made a mistake: I created one single album, and then got about 20,000 photos uploaded into this one/single album.

Now I am thinking there are way too many (20,000) photos in this one single album. I think I shall create a few albums (say one for each calendar year such as "Album 2013", "Album 2014",..., "Album 2017"), and then mass-move photos from the current single album into these newly created albums. Is this possible, and if yes, how?

Thank you in advance


phill104

Sorry, this was probably missed. I think much of the support team including myself are very tied up at the moment.

As you say, that is a lot of images in one album. Not necessarily a problem speed wise, but can make searching for am image a pain. However, it is a lot of work to move images manually between albums via the gui. It could also be done by manipulating the database as each image is given an album ID so the software knows what album to put each image into when displaying them. However, how would you know which images to move to what album? Use that method to simply split each album into smaller ones but it would not give you any choices of what goes where.
It is a mistake to think you can solve any major problems just with potatoes.

gmc

What Phil said...
But... If there is some picture data (portion of the filename or other data available from the database or the image file itself) that could determine what album a photo should go into - it would be something that a script could be written to do...
You would need to define what the 'rules' would be - and the album names (or aid) to use in each case...

For example - I typically name my picture Dyy_nnnn.jpg - where yy is the year... Very simple then to write a script that says if the filename begins with D15 then move it to album number 10 (titled 2015 Pictures).

Another option is the ctime (Unix timestamp) stored in the database (cpg_pictures) which should be when the file was uploaded... If upload date rather than the date the photo was taken makes sense - could be easily scripted too.
(mtime is a datestamp field - and for some of my photos - closely matches ctime - but it does seem to be updated - possibly by some admin toold - as some of my photos loaded in 2004 have a 2016 mtime... but 2004 ctime.

Do either of these sound workable?

Thanks!
Greg
My Coppermine Gallery
Need a web hosting account? See my gallery for an offer for CPG Forum users.
Send me money

xiaolu

Thank you both for the replies.

Yes, I intend to move many many images from one single album into multiple albums.

Based on image file names of the images in the current single album, I know what images shall be moved to what newly created albums.

The image names are currently of this format:
attchID_X_postID_Y_whateverName.(extention), for example:  attachID_36_postID_212_image.jpg

So the intended move would be based on attachID from file name, like:

Those images with file name attachID_1_.... to attachID_500 (for example) shall be moved to Album A
Those images with file name attachID_501_.... to attachID_1000 shall be moved to Album B
Those images with file name attachID_1001_.... to attachID_1500 shall be moved to Album C
...

I guess ia script or some MySQL update queries (after those new albums are created) would work...?

Thanks again.

gmc

A script is easiest... I've attached a sample based on your naming conventions (which actually made the split easy...)
zip file contains a single file - albumsplit.php.

I've 'tested' from the standpoint of correct syntax and SQL generation - but I don't have the same naming convention you do...
Script is based on 1.5.44 code (uses function added in 1.5.42) - which it appears you are already running.

As you will see in the code - a few updates for you to make:
// Define your new albums and get 'aid' for each (browse `cpg15x_albums`)
// Code updates (use simple text editor or PHP editor if available):
// - $process_album - specify album id to be processed (where pictures are currently assigned...)
// - $album_array   - update below array to specify correct keys and aids for split.
// Save changes and upload this file to cpg root directory
// Login as CPG admin and execute:  http://your_cpg_path/albumsplit.php
// Validate results
// change $update from FALSE to TRUE
// re-upload - and run again for real...
// Optional: set $limit to number of records to process in a run.


The $album_array is the roadmap for reassigning:
// album_array defined as 'upper_limit' => 'aid_to assign' - last entry will also be used for anything greater
$album_array = array('500' => '3',   
                     '1000' => '4',
                     '1500' => '5',
                    );


By default - NO UPDATES will be made.. It will just output the SQL that would be used.
Until you change $update from FALSE to TRUE - then it will update your data...

PLEASE MAKE A BACKUP of at least cpg15x_pictures (using your high level for the table) before running in update mode.
It is possible the script will timeout depending on your hosts limits... It can be rerun and will continue (only selects pics assigned to the single album you want to remap... so anything already reassigned will be skipped next time through.) - OR you can set $limit in code to a number that fits in your limits...
Thanks!
Greg
My Coppermine Gallery
Need a web hosting account? See my gallery for an offer for CPG Forum users.
Send me money

xiaolu

Thank you very very much for the help and for even providing the script/code. I will give it a try. Thanks again, and happy new year to you!