Fork me on GitHub

BASH: rename files

A simple rename example using again the mighty awk and xargs
ls -l *.xml | awk '{print $9}' | xargs -t -i mv {} {}.old

Explanation:
ls -l *.xml -> easy! list the xml files in a folder
awk '{print $9}' -> output just the name of the file
xargs -t -i mv {} {}.old -> rename it adding at the same filename the extension “.old”

I know, I know … my explanation is crap: blame my laziness :)

No comments yet.


Leave a comment

(required)

(required)