Skip to content

Instantly share code, notes, and snippets.

@drjwbaker
Last active August 5, 2016 15:20
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 drjwbaker/6c2481525ba26603665079e562707f60 to your computer and use it in GitHub Desktop.
Save drjwbaker/6c2481525ba26603665079e562707f60 to your computer and use it in GitHub Desktop.
rename files in directory and sub-directories so that all spaces are replaced by dashes
# rename .jpg files in directory and sub-directories so that all spaces are replaced by dashes
## this one works!
find . -name "*.jpg" | while read filename; do newname=`echo $filename | sed -e 's/ /-/g'`; mv "$filename" "$newname"; done
## old attempt
for oldname in *; do newname=`echo $oldname | sed -e 's/ /-/g'`; mv "$oldname" "$newname"; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment