Last active
August 5, 2016 15:20
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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