Integrated filename cleanup util?

I'm not finding anything in the plugin repository, or ZP directly, so thought I'd ask before I built one for myself...

Has someone built a utility within ZP that can be kicked off to find and cleanup file names within an album? Optimally, this utility would look for any file name that contains spaces, and/or caps, and or other dodgy characters and change them to all-lower, browser and php-friendly characters.

Now, I know ZP handles this when uploading via ZP directly, but I've got 100's of photos that I've ftp'd which contain all manner of camel-case, spaces, tildes, and such.

This request comes after a day's worth of fiddling around trying to figure out why imagecreatefromjpeg() was acting so inconsistently...was it something to do with PHP config, ZP's getUnprotectedImageURL(), htaccess, etc, etc?? No...it was a couple of specific images with spaces in their file names that I happened to be selecting occasionally as part of a test routine :~/

Comments

  • I have not heard of any such plugin/function. It could be done, but not quite as simple as it seems. In addition to finding the files it would have to use the Zenphoto rename capability so as not to disassociate any datbase info from the file.

    It sounds an interesting project. Perhaps I will build such a plugin.

    Quick question, though. You said that filenames with a space in them caused you some difficulties? That would be an unfortunate thing as spaces are really quite acceptable as characters in a filename.
  • Ah - the database side of the equation...I hadn't considered that, but true - it adds a significant layer of challenge. Perhaps a top -> down approach scanning (at the very least) _images for filename contains " ", updating these records, and building the list to change the same at the file system level, doing all the traversals, etc thru the albums. I can imagine all sorts of possible integrity issues if this wasn't done just right.

    Specifically, I've narrowed down a problem with PHP's imagecreatefromjpeg() where it dies with an unrecoverable error when I pass a file name with a space in it.

    What I'm working on is a postcard hack which passes a handful of elements (background, stamp, a short message, font, and the image) to a script that compiles everything into a jpeg (imagecopymerge()) and sends it to a recipient.

    Since it seems that imagecreatefromjpeg() is so finicky to begin with, and I have hang-ups with weird file naming from my old unix admin days, it seemed all the more reason to think about a cleanup util. This, I'm sure, is a corner-case scenario as ZP has no apparent fundamental problem with any file naming I've thrown at it. It's probably best to account for this pre-upload unless there is some other reason/use case in which you see this type of utility as a worthwhile endeavor.
  • I have something that seems to be working. However, not tried on the number of images you have, so script timeout might be an issue.

    It will be in the development release after the 1.4.0 build is cut. You can give it a try then and we will see if it needs tweaking.

    It makes use of the SEO filter, so to change what it does to filenames you will need to change that filter. (Seemed reasonalable since that is what the back-end upload uses.)

    Must be something more that files with spaces in them. That function is used to process any image. Certainly i (had) a lot of images with spaces and never had a failure to render.

    The one thing I have noticed is that there is strange behavior when creating an image with some characters in the folder name. I don't remember the specifics, but there is a work-a-round somewhere in ZP that first creates the folder then creates the image when caching an image. You also get strange folders created as a side effect of this. We leave them as we never know when they will pop up.

    So far I have seen this only on names with diacritical marks. But who knows, maybe there are other instances.

    Anyway, thanks for the post. It was interesting to make this utility. Should be available in a few days.
  • Wow - I'm thoroughly impressed! I'll keep an eye out for that 1.4.0+1 release in a few days, test it out, and report back.

    I can't help thinking that what I've run into is multi-layered, but the only consistent cause/effect I can nail down is the space-in-filename scenario. I'll keep messing with it - if I uncover some other aspect, I'll post here.

    Thanks again!
  • It is up. Try tonight's nightly build. Overview page, SEO cleanup utilities button. Your feedback is appreciated.
  • I'll definitely give it a go as well. Have a few albums that I've been dreading renaming because it's a lot of tedious work. Hopefully this will alleviate it.
  • The SEO Cleaner worked like a champ, and honestly a ton quicker than I thought it would be. My gallery only has just over 1k items though, but I was quite impressed. Thanks for the great work on it!
  • ^^ x2 - I tried it today in a small-ish local test and found that it ran very quickly, and "end-to-end" successfully.

    Thanks again for this...very helpful!
Sign In or Register to comment.