I am attempting to rename all directories and files to uppercase with a shell script. What I have works, but not for sub directories. As the directory names are changing during the scripts execution I get things like mv: cannot stat './def/two/three': No such file or directory
I have tried using -depth
with find so it would rename from the bottom up. But still run into the same problem. I though about using cut
to break apart the path on /
and rename that way, but am at a loss.
Here's what I have:
for i in `find . -name "*[a-z]*"`
do new_name=`echo $i | tr '[a-z]' '[A-Z]'`
mv $i $new_name
done
I would appreciate any direction as I feel like this should be a common task, but failed to find a working solution from some Google searches.
Please note, I can not use rename
as it not supported by my distro.