Created
February 10, 2015 09:46
-
-
Save Bonno/2351647fb163c1db7ae4 to your computer and use it in GitHub Desktop.
Replace special character in all files in given location
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
#!/bin/bash | |
#FS=' | |
#' | |
##strip special character: ' | |
character="'" | |
replace="_" | |
j=`find $1 -printf "%d\n" | sort -u | tail -n 1` | |
j=$((j-1)) | |
echo "Max dir depth:" $j | |
for (( i=0; i<=j ; i++ )) | |
do | |
##limited | |
#for name in `find -mindepth $i -maxdepth $i -iname "*$character*" -printf "%p\n"` | |
##recursive | |
for name in `find -iname "*$character*" -printf "%p\n"` | |
do | |
newname=`echo "$name" | tr "$character" "$replace"` | |
echo "$name" "$newname" | |
mv "$name" "$newname" | |
done | |
done | |
########## |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment