Bash Rename All Files in Dir

Something I have never known how to do in Linux, is rename a directory full of files. (Crazy right?!) Fortunately for a noob like msyelf, Sam Bisbee does know how to do this, and showed me today. In the following example, I am renaming a directory of files with no file-extension, and moving them to the same location with “.png” appended.

for file in `ls` ; do mv $file $file.png; done

Simple. Useful. Documented.


Contact Us

We'd love to hear from you. Get in touch!


P.O. Box 961436
Boston, MA 02196