Batch add with automatic album/cat structure from directory tree. - Page 4 Batch add with automatic album/cat structure from directory tree. - Page 4
 

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

Batch add with automatic album/cat structure from directory tree.

Started by Nibbler, January 21, 2005, 11:37:57 AM

Previous topic - Next topic

0 Members and 6 Guests are viewing this topic.

Paver

Something's weird.  The error is being caused because the field position is a number field and cannot be assigned to a string like 'a.jpg'.  I checked the timer.php script and it has an error in that it sends the filename where the position should be because it has an extra parameter in the function call.  But it works fine for me.  Maybe MySQL 4 will realize you are sending a string and ignores it whereas MySQL 5 won't let you do this and gives the error.  Or maybe both servers have a strict setting and mine has it off whereas yours has it on.

In any case, look for this line in timer.php:
if (add_picture($aid, $dir_name, $sane_name, $file_name)) {
and replace it with this:
if (add_picture($aid, $dir_name, $sane_name)) {

Let us know if it works.  Since I don't have this issue, I cannot easily test it.  I assume the error in timer.php is due to an earlier prototype for the add_picture function.

Prisoner_24601

Paver deserves WAY more karma points.

That worked!  Once again, using the directory structure I mentioned above, it created the album and category, but this time it uploaded my file and added it to the CPG database.  No errors.

I do want to test further, because the script didn't (earlier, before Paver's changes) skip already added files/galleries, as "was advertised" -- and I want to test with lots of JPEG's -- but I think this is probably gonna work pretty darn well.

I'll keep y'all updated on the progress.

(Also remember, if you're trying this on CPG143, that you have to change the lines that say "db_query" to "cpg143_db_query".  That's on pg. 2 of this thread.)

Paver

Quote from: Prisoner_24601 on January 19, 2006, 04:54:04 PM
(Also remember, if you're trying this on CPG143, that you have to change the lines that say "db_query" to "cpg143_db_query".  That's on pg. 2 of this thread.)
Actually, it's cpg_db_query.  But the best thing to do is to download the script that's compatible with both 1.3 & 1.4 that's somewhere in this thread.  The flux_donnoman mod timer script.  I don't feel like looking for it now.  That's the one I've been using.

I added a "check files only" option so that I can do a trial run that won't add anything.  I always use that before running a real run of the timer script.  That way I'm sure I didn't add an extra folder here or there or have a filename with quotes etc.  As I mentioned earlier in this thread, I'd like to contribute my additions but I think it's time to make this into a plugin and I haven't quite done that yet - that's when I plan to submit them.  Others are welcome to steal my thunder, or we'll see when I get to it.

Prisoner_24601

I went back and got the Flux-Donnoman one instead of the one in the first post in this thread (which says it's the newest) and updated it as you describe.  Works just great -- and I tried a couple hundred pictures and categories.

The only thing I did have to do was ask my webhost to increase the timeout in PHP.INI.

Now I'm off to search if there's a plugin that improves the response of catmgr.php ....  ;D

howie10

Hi. I love the idea of this mod.  :P

Has anyone got it working with a local windows installation, (win2k)?

I am logged on through http://localhost/, and when I do http://localhost/coppermine-install-directory/timer.php I just get the standard 'error while processing..' error which (in debug mode) gives an initial message of:

  While executing query "INSERT INTO copperminecategories (pos, parent, name) VALUES ('10000', '0', 'personal')" on 0
  mySQL error: Field 'description' doesn't have a default value

I do run MYSQL5, but I have followed the instructions above already in the hope that it solves it. Also, I have set the folder I made under /albums as writeable by everyone.

Thanks (in advance).

Prisoner_24601

Did you try ...

Quote from: Prisoner_24601 on January 19, 2006, 03:34:52 AM
I was getting the same error as fade2grey (CPG 1.4.3, Win2K3, PHP 5, MySQL 5) and, at the advice of my webhost, I:

* Booted up phpMyAdmin
* Found the table "cpg143_categories"
* Set the DEFAULT column for "description" to NULL

... and then do the suggestions from Paver?

howie10

Quote from: Prisoner_24601 on January 31, 2006, 10:06:59 PM
Did you try ...

... and then do the suggestions from Paver?

Hi. I already did the paver suggestions, but I had downloaded the 'fix' version of the script so I didn't think the 'null' change was necessary!

So, as a relative newbie to mysql and php, how do I access myphpadmin on my win2k system which is running php5 and mysql5?

Thanks.

Nibbler


howie10

I am silly. I was doing some searching and it was all there in front of me. I'm with you now! (sorry).

However, I'm running V1.4 and all my tables start with "coppermine"...

I presume I should be changing: copperminecategories?

Prisoner_24601

If your database's name is "coppermine", then the tables will be in the form of "coppermine_categories".  Note the underscore.

Easier to see once you get phpMYAdmin installed.

Paver

Quote from: Prisoner_24601 on January 31, 2006, 11:51:27 PM
If your database's name is "coppermine", then the tables will be in the form of "coppermine_categories".  Note the underscore.
Not quite correct.  The database name, whatever it is, would go in front of the table name, separated with a period - if you wanted to explicitly state the database name.  Usually you're in the database, so only the table name is necessary.  The table prefix for Coppermine *does* go in front of the "categories" for the categories table.  The prefix does not have to have an underscore, although most people do use the underscore.  Judging from the error message listed, howie10's table prefix has no underscore.

Quote
Easier to see once you get phpMYAdmin installed.
Quite true.

howie10

Well. It worked! Thanks very much.

Only one thing, I had the structure wrong in the first place, so I deleted all the categories and tables in comppermine and started again. However, timer.php re-creates the cats and albums, - but then skips all the file uploads because it says they already exist!

I've even tried uploading a filesystem with different folder names, - and then overwriting it with my original one, but it still thinks the files exist.

Any ideas?

Paver

If you only deleted the categories & tables, you didn't delete the pictures, did you?  You need to delete the categories & albums & pictures to start from scratch, then use timer.php to do its thing.  Then in the future, you add files & folders and run timer.php to add only the new ones.  Make sure you don't rename any categories or albums or timer.php will think the folder-named categories & albums don't exist and it will recreate them.  That's my main plan for a plugin; to take care of renames in Coppermine.

Also make sure you don't add folders in such a way that a previous album becomes a sub-category, if that makes sense.  You have to keep the levels straight since there are no sub-albums.

howie10

Ahh. Yes, it all makes sense, however, I now can't delete the pictures because I have a beautiful category structure - with no pictures in it. However, the main page footer tells me that there is 1600 pictures in 106 albums and 43 categories.

Somewhere, the application is holding info on the original pictures and thinks they are still there? (I suppose).

???

Paver

Well I assume you emptied the tables directly in phpMyAdmin?  If so, you did something Coppermine cannot count on since it would never do that itself.  In effect, you hacked the database.  Empty the album table, the category table, and the pictures table, then try again.

howie10

You are correct. I did end up deleting categories using phpmyadmin. However, I did this because when I tried to do it in coppermine, they were locked and couldn't be deleted. Sorry, I can't remember the exact error message.

I have just deleted everything from the 3 databases as you suggest, and it's worked a charm. I appreciate your patience. You're a star!

This is an awesome mod. Thanks.

H.

Paver

Nibbler's the star for the mod; you're welcome for the support. 

I find this mod extremely useful as well and hope to make it more robust some time.  Others are welcome to do it instead or in addition - my toes are tough.

Oh, since some words were incorrectly used in the past few posts, here's a quick overview:

  • database: a collection of tables
  • table: a collection of records with fields
  • record: a collection of values in fields (a.k.a. a "row" in spreadsheets)
  • field: a "column" in spreadsheet parlance

howie10

That's really useful info. And thanks again to Nibbler!   ;D

I am only having one slight problem now; timer stops after a few minutes (appears to crash). Not a hang, but the browser just goes to the 'no webpage found, - check dns setting etc), error.

I don't suppose there's a method of logging the script so that I can see which file/s causes this is there?

Logging would also be good to give a list of files it fails to load, so that I can manually convert formats etc. (just a suggestion).

Thanks again.

H.

Paver

Depending upon your webserver's PHP settings, this is probably a PHP timeout issue. There are other threads that discuss this.  If you cannot adjust your PHP settings, then you have to work with what you have.

This script has a delay between requests ("sleep betwen additions") and a number of images to run on each page load ("limit additions per refresh").  Adjust these until things work and don't timeout.  Safe values I would guess would be a not-so-long delay (500-1000 ms) and a small number for refresh (5 or 10), depending upon how long it takes to create each thumbnail & intermediate image.

Yes, it would be good to log the operation of this script, ideally to the regular Coppermine log.  There are probably a few lines you could add to do that now, but I don't have time right now to check that.

howie10

Thanks again for the reply.

Well, I've adjusted my timeouts in php.ini to 600 and also the filesize to 8m.
I've also changed my apache conf file timeout from 120 to 600. - All to no avail.

I wonder if (as a temp workaround), I can log into coppermine and upload the files in the empty directories using the standard coppermine interface. Or will this confuse things the next time I run timer.php?
???