Skip to content

Instantly share code, notes, and snippets.

@irmowan
Created June 9, 2016 15:33
Show Gist options
  • Save irmowan/923453234eb227e87274c2dc97c595a6 to your computer and use it in GitHub Desktop.
Save irmowan/923453234eb227e87274c2dc97c595a6 to your computer and use it in GitHub Desktop.
Rename files
j=1
l=10
word="close"
for i in `ls | grep 1`
do
newWord=`echo $i | cut -d _ -f 2`
if [[ "$word" != "$newWord" ]];then
let j=1
fi
if [[ "$j" -lt "$l" ]]
then
k=0$j
else
k=$j
fi
newName=`echo $i | cut -d _ -f 1,2`_$k.wav
#echo $newName $word $newWord
echo "Renaming file from "$i" to "$newName
mv $i $newName
((j++))
word=$newWord
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment