I have a directory that contains thousands of sub-directories. Structure like this:
Dirs:
- 1
- 2
- 30
- 109
I want to rename all the directories by adding 10000 to their current name. E.g.
Dirs:
- 10001
- 10002
- 10030
- 10109
I have written this script
for f in *; do
if [[ -d $f ]]; then
echo $f
newd='expr $f + 10000'
echo $newd
mv $f newd
fi
done
from the 2 echo
s, I can see 1 and 10001.
But the mv
actually move all my directories into a new folder called newd.
I tried $newd, doesn't work as well.
What could be done to make this thing works?