Skip to content

Bash snippet: Remove text from filenames

2011 August 26
by Tedb0t

Today I had a directory full of mp3 files for a Flash game that each had the text “woman01” in them. ¬†Since I wanted to just keep the rest of the filename, I put together this Bash one-liner:

for f in *; do mv $f ${f/woman01/}; done

Simple and effective!  Bash has a surprising array of string-manipulation capabilities, which I learned about here.

Related Posts:


Comments are closed.