28 October 2004
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.
- Bush country
28 October 2004
- Urwid - curses-based UI/widget library for Python
30 October 2004
- Related by keywords:
- To readline() or readlines()
12 March 2004
- bool is instance of int in Python
05 December 2008
- Reciprocal lesson about gender perspectives
02 September 2011
- Nginx vs. Squid
17 March 2009
- How and why to use django-mongokit (aka. Django to MongoDB)
08 March 2010
- Nasty surprise of Django cache
09 December 2008
- IssueTrackerProduct now officially abandoned
30 March 2012
- Google Calendar, iCalendar Validator but not bloody Apple iCal
09 April 2009
- On the command line no one can hear you screen. Or can they?
03 May 2012
- In Django, how much faster is it to aggregate?
27 October 2010
- tempfile in Python standard library
07 February 2006
- Random ID generator for Zope
02 September 2005