Skip to content. | Skip to navigation

Personal tools
Log in
Sections
You are here: Home Knowledge Rename all .ogg files in one directory to .oga

Rename all .ogg files in one directory to .oga

by Akaname last modified Jul 04, 2011 04:16 PM

This will rename all *.ogg files in the current directory and its subdirectories to *.oga files. See the Linux manual pages "man bash", "man find", "man mv", "man sed" and "man pcrepattern".

All filename results from find are piped line by line to read and then processed by mv, editing the new filename with sed. This ensures that all paths with whitespace characters are processed correctly.

find . -type f -name '*.ogg' | while read filename; do mv -v "${filename}" "`echo "${filename}" | sed -e 's/\.ogg$/\.oga/'`"; done
Filed under:
Akaname (垢嘗) licks it...

Sekien Akaname

Akaname is a long tongued japanese demon

Usually, it comes in the night to lick the mud out of the bathtub. Take care and don't forget to clean your bathtub properly!