I want to rename files in a dir then change the file name base on the dir name this is what I had but it's not quite working
find . -type d | while read dir
do
cd "$dir"
find . -name \*.rar -exec unrar x '{}' \;
find . -name \*.avi -exec mv '{}' "$dir.avi" \;
cd ..
done
root/directory.1.with.rar.in/
root/directory.2.with.rar.in/
root/directory.2.with.rar.in/
root/directory.2.with.rar.in/
root/directory.2.with.rar.in/
I want all the rar in the Directory to be extracted in root then renamed with the name of the directory it was extracted from.