Skip to content

Instantly share code, notes, and snippets.

@ryoco
Created November 19, 2012 14:03
Show Gist options
  • Save ryoco/4110809 to your computer and use it in GitHub Desktop.
Save ryoco/4110809 to your computer and use it in GitHub Desktop.
rename(replace) filenames
for filename in `ls FOO_*.html`; do newname=`echo $filename | sed -e 's/FOO/BAR/g'`; mv $filename $newname; done
@yyuu
Copy link

yyuu commented Nov 19, 2012

bash/zsh 拡張使っても問題ない場面であれば以下のようにも書ける。

for f in FOO_*.html; do mv "${f}" "${f/FOO/BAR}"; done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment