I had the problem today that several files in a directory started with an
_ underscore character. (e.g.
_red.gif). Instead of manually renaming each file used the power of shell and python to solve it. (and some help from my collegue of course). Fortunately none of the files had an underscore in the middle of the name so I could keep the command quiet simple:
find -iname '_*' \ | xargs python -c \ 'import sys;print "\n".join(["mv %s %s"%(x, x.replace("_","")) for x in sys.argv[1:]])'\ | sh -s
Hardcore UNIX geeks might laugh at me for using a few characters too many or not using sed properly. Windows users might laugh at me for even trying and would prefer to do it manually or pay $40 for a shareware to do it. Well, it worked.