Rcjp's Weblog

January 7, 2007

Renaming Groups of Files

Filed under: python, unix — rcjp @ 4:13 pm

I have done it in the times in the past, but I always forget the-right-way because different unix shells do loops differently etc, so I now always use ipython to e.g. lowercase all filenames in a directory…

    In [14]: import os

    In [15]: !! ls

    In [16]: for f in _15: os.rename(f, f.lower())

and for doing that recursively of course just do

    !! find . -type f


Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Blog at WordPress.com.

%d bloggers like this: