Last active
August 29, 2015 14:18
-
-
Save brownman/aa065e8f6f404aeb0adf to your computer and use it in GitHub Desktop.
rename filename - beware: must cd to directory before running it
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
clear | |
#Example: rename filename from article to phone: | |
#from=article | |
#to=phone | |
from=article | |
to=phone | |
cmd='find * -type f ' | |
echo $cmd | |
list=$( eval "$cmd" | grep $from ) | |
for item in $list;do | |
test -f $item && ( | |
file1=$( echo $item | sed "s/$from/$to/g" ) | |
echo $file1 | |
mv $item $file1 | |
test -f $file1 | |
) | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment