Skip To Main Content

Bash Rename All Files in Dir

Posted by Alistair Macdonald

Mar 09 2011

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.

Posted by
Alistair Macdonald
on March 9th, 2011

Comments

We moved off of Disqus for data privacy and consent concerns, and are currently searching for a new commenting tool.

Contact Us

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