Bashing

There’s always something satisfying to solving problems, even small ones, via programming.

As chief cook and bottle washer on my work site, I’m not only architecting, designing, coding and programming, but also frequently preparing new content. Often this content comes with its own small headaches.  For instance, we receive product image files from vendors whose file names begin with the product ID (good) but end with some other text (bad).  With a few files of course the fastest fix is just to edit the titles directly, but when scores (or hundreds, or thousands) need fixing, it’s time to automate.

I could write a PHP CLI script for this, and it would be a good time to explore Node; but then again, Bash is there at hand.  Simple is usually (always?) best.

I’m not a Bash pro, though I’m on the command line all the time. Fortunately the Internet is at our fingertips. Shell script lookup! The need to learn is an itch needing a scratch.

Just a few lines: Iterate the files, split the file names on spaces or whatever, mv to the new name, and Robert remains your mother’s brother.

This entry was posted in Uncategorized. Bookmark the permalink. Comments are closed, but you can leave a trackback: Trackback URL.