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.

This entry was posted by Al MacDonald on March 09, 2011 in Bash, Terminal and Ubuntu.

Comments

Author

This entry was posted by Al MacDonald on March 09, 2011 in Bash, Terminal and Ubuntu.

Recent posts from this author

Related on the Bocoup Blog

Advertisement

Twitter

Google+