Delete Empty Albums? Delete Empty Albums?
 

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

Delete Empty Albums?

Started by Prisoner_24601, September 08, 2006, 06:57:44 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Prisoner_24601

CPG 1.4.9 -- brand new fresh install, too.  Very, spiffy, folks!
MySQL 4.1.7
PHP 5.1.1
Win 2003 Server

I've done a lot of moving and other changes to my Gallery and there are a lot of albums that are now left with zero pictures.  Is there any way of deleting all these albums with zero pictures, other than clicking the "delete" button for each album?  I do have phpMyAdmin ....

Thanks in advance!

==========

Background:

I read Stramm's post (I DO use the Search Engine!  I do!):

Quote from: Stramm on July 01, 2006, 12:40:19 PM
delete the albums and pictures in them and the user galleries category disappears
to delete empty albums
http://forum.coppermine-gallery.net/index.php?topic=31917.msg148529#msg148529

and went to the linked thread, where it says ...

Quote from: Stramm on May 29, 2006, 02:55:44 PM
if the album is empty you won't see it. For that click 'properties' next to any visible (public) album. Now you'll see a dropdown box on the top right side. Look for user galleries here. User galleries can be found looking for () and the users name in it. Like '(Stramm) My Album'. Select the album, then click 'parent category' (left of the dropdown). Magic... you'll now see the empty album and can hit the 'delete' button

... however, as you can see, you can still see the empty albums, even if you're not logged in.  Probably this is because I (Administrator) uploaded these albums.

Nibbler

This should do it. Backup first.

DELETE FROM a USING cpg_albums AS a LEFT JOIN cpg_pictures AS p ON p.aid = a.aid WHERE p.pid IS NULL

Not a plugin contribution, moving.

Prisoner_24601

Thanks for moving.  Sorry.  Too many browser windows open.

Nibbler

Just to note:If you use the 'linked files' feature then don't use the above.

Prisoner_24601

I think that worked!  Deleted 194 entries, which "sounds" about right.  Thanks very much: saved a lot of time!

Another note to anyone else that tries this: where Nibbler has "cpg_", make sure you substitute the correct prefix for your tables!  Mine's "cpg143_".