#!/bin/sh for i in *; do if [ -d $i ]; then echo "renaming content of $i ..." cd $i for j in *; do if [ -f "$j" ]; then dst_file="`echo $j | sed 's/\ /\\ /g' | sed 's/(/\\(/g' | sed s'/)/\\)/g' | sed 's/&/\\&/g' | sed 's/!/\\!/g'`" trg_file="`echo $j | sed 's/\ /_/g' | sed 's/&/_/g'| sed 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ()-,!/abcdefghijklmnopqrstuvwxyz_____/'`" if [ "$dst_file" != "$trg_file" ]; then mv "$dst_file" $trg_file chmod 644 $trg_file fi fi # assume albums if [ -d "$j" ]; then cd $j album="`echo $j | sed 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ()-,/abcdefghijklmnopqrstuvwxyz____/'`" for song in *; do dst_file="`echo $song | sed 's/\ /\\ /g' | sed 's/(/\\(/g' | sed s'/)/\\)/g' | sed 's/&/\\&/g' | sed 's/!/\\!/g'`" trg_file="`echo $song | sed 's/\ /_/g' | sed 's/&/_/g'| sed 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ()-,!/abcdefghijklmnopqrstuvwxyz_____/'`" if [ ! -f ../${album}__${trg_file} ]; then mv "$dst_file" ../${album}__${trg_file} chmod 644 ../${album}__${trg_file} fi done cd .. rm -rf $j fi done cd .. fi done