Hello,
I'm new to unix and I have to rename all folder fron the current folder from a name like "xx - Name of the Folder" to "Name of the Folder - xx".
xx is a number ...
Can somebody, please, help?
Thank you!
Hello,
I'm new to unix and I have to rename all folder fron the current folder from a name like "xx - Name of the Folder" to "Name of the Folder - xx".
xx is a number ...
Can somebody, please, help?
Thank you!
ls -l | awk ' /^d/ { print $NF } ' |
sed "s/^\([0-9]*\)\(.*\)/mv & \2\1/" | sh
What about if folder name contains, spaces?
find . -type d -print | sed -e "s;\./\([^/]*\).*;\1;" -e "s/^\([0-9]*\)\(.*\)/mv \"&\" \"\2\1\"/" | sh
With zsh (and if zmv is available for your zsh):
autoload zmv
zmv '(*) - (*)' '$2 - $1'
anbu23,
Thak's but the line seems to be a little wrong: "mv: cannot access 2005 - Broken Flowers" ..
Don't know why... I'm root on this session...
Or more portably:
for i in [0-9]*;do # adjust the globbing for your needs
mv "$i" "${i#*- } - ${i% -*}"
done