Skip to content

Instantly share code, notes, and snippets.

@digitaljhelms
Created July 16, 2012 23:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save digitaljhelms/3125794 to your computer and use it in GitHub Desktop.
Save digitaljhelms/3125794 to your computer and use it in GitHub Desktop.
Bash CLI function to change the file extension for multiple files at once
# bash function, usage: $ ext [ext1] [ext2]
function ext() {
for f in *.$1; do mv $f `basename $f .$1`.$2; done;
}
@digitaljhelms
Copy link
Author

With this this helper function you can change the file extension for multiple files at once by simply typing ext foo bar; this would rename all files in the current directory with the extension .foo to the extension .bar.

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