Skip to content

Instantly share code, notes, and snippets.

@kevinsalter
Last active December 18, 2015 23:28
Show Gist options
  • Save kevinsalter/5861456 to your computer and use it in GitHub Desktop.
Save kevinsalter/5861456 to your computer and use it in GitHub Desktop.
Search and replace on command line to rename files
# change *.* to *.jpg to only target JPGs, for example
# and to customize the search...
# sed -e 's, what you're searching for goes in this space , what you want to replace it with goes here ,g'
#the default example here with turn spaces into nothing ( i.e. remove all spaces from file names )
for i in *.*; do mv "$i" "`echo $i | sed -e 's, ,,g'`"; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment