143 total views,  1 views today

When building or updating websites for people, we often get a zip folder of images for use in a gallery or carousel. There’s many ways to plug these image files into your markup, but one thing we like to do is make sure they’re renamed. For most projects we prefer numerical order. It’s easy to find the image you want when looking at the code and it saves a few extra characters on the overall size of the file. This can be time consuming, but with a little script, it only takes a few seconds to rename all your images in a particular folder in numerical order.

I’m using Terminal on my Mac in this video but Windows users can use Git Bash.

This Script could wreck a bunch of stuff on your computer so make sure you know what you’re doing before trying this.

ls -v | cat -n | while read n f; do mv -n "$f" "$n.jpg"; done 

* Make sure you’re in the correct folder or this will rename all files in the directory it runs on and change the extension!*

No responses yet

    Leave a Reply

    Your email address will not be published.