Wednesday 26 February 2014

How to change extension of multiple files in Linux?

When files are in same folder:

rename 's/.abc$/.edefg/' *.abc


Recursively rename files:

# Bash
# Also requires GNU or BSD find(1)
# Recursively change all *.foo files to *.bar

find . -type f -name '*.foo' -print0 | while IFS= read -r -d '' f; do
mv -- "$f" "${f%.foo}.bar"
done



From:
http://askubuntu.com/questions/35922/how-to-change-extension-of-multiple-files-from-command-line

Also see:

http://mywiki.wooledge.org/BashFAQ/030

No comments: