Rename list of files within a given directory
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 | |
# @autor: Adriano Rosa <http://adrianorosa.com> | |
# @file: renames.sh | |
# @description: basic file renamer | |
# @usage: ./renames.sh path/ .html .php | |
criteria=$1 | |
re_match=$2 | |
replace=$3 | |
if [[ $criteria && $re_match && $replace ]]; then | |
for i in $( ls *$criteria* ); | |
do | |
src=$i | |
tgt=$(echo $i | sed -e "s/$re_match/$replace/") | |
mv $src $tgt | |
done | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment