I need to lower all upper-cases of file and folder names from a path, recursively inside other folders found; I need to do that with a bash script.
Here my code:
for file in $(find $1 -type f)
do
tmp=$(echo $file | rev | cut -d/ -f1 | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz)
tmp2=$(echo $file | rev | cut ????)
tmp=$tmp$tmp2
mv $file $(echo $tmp | rev)
done
for file in $(find $1 -type d | sort -r)
do
tmp=$(echo $file | rev | cut -d/ -f1 | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz)
tmp2=$(echo $file | rev | cut)
tmp=$tmp$tmp2
mv $file $(echo $tmp | rev)
done
The problem is at line 4, [tmp2=$(echo $file | rev | cut ????)]
I don't know how I can select all the fields delimited with / after the first field.
With line 3 I can isolate the file name and with the tr command modify all upper-cases, but then comes the trouble. Same for folders t the second 'for' construct.