Advanced search  

News:

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

Pages: [1]   Go Down

Author Topic: How to move/split lots of photos from one single album to multiple albums  (Read 2243 times)

0 Members and 1 Guest are viewing this topic.

xiaolu

  • Coppermine newbie
  • Offline Offline
  • Posts: 5

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
Logged

xiaolu

  • Coppermine newbie
  • Offline Offline
  • Posts: 5
Re: How to move/split lots of photos from one single album to multiple albums
« Reply #1 on: December 19, 2016, 12:26:13 pm »

Guess no one know?:-)
Logged

Phill Luckhurst

  • Administrator
  • Coppermine addict
  • *****
  • Country: gb
  • Offline Offline
  • Gender: Male
  • Posts: 4483
    • Windsurf.me

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.
Logged
It is a mistake to think you can solve any major problems just with potatoes.

gmc

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 723
    • GMC Design Photo Gallery

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?

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

xiaolu

  • Coppermine newbie
  • Offline Offline
  • Posts: 5
Re: How to move/split lots of photos from one single album to multiple albums
« Reply #4 on: December 30, 2016, 09:54:06 pm »

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.
Logged

gmc

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 723
    • GMC Design Photo Gallery

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:
Code: [Select]
// 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:
Code: [Select]
// 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...
Logged
Thanks!
Greg
My Coppermine Gallery
Need a web hosting account? See my gallery for an offer for CPG Forum users.
Send me money

xiaolu

  • Coppermine newbie
  • Offline Offline
  • Posts: 5

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!
Logged
Pages: [1]   Go Up
 

Page created in 0.017 seconds with 21 queries.