Skip to content

Instantly share code, notes, and snippets.

@brownman
Last active August 29, 2015 14:18
Show Gist options
  • Save brownman/aa065e8f6f404aeb0adf to your computer and use it in GitHub Desktop.
Save brownman/aa065e8f6f404aeb0adf to your computer and use it in GitHub Desktop.
rename filename - beware: must cd to directory before running it
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