Newbie Question: Shell-like Scripting in Python?

Scott Meyers Usenet at aristeia.com
Tue Oct 1 22:54:07 EDT 2002


I'm an experienced programmer, but I'm new to Python.  I'm working my way
through "Learning Python," and that's fine.  One of the things I want to do
is parse mp3 files and edit their ID3 tags, but I know that I must crawl
before I can run, and I'm happy to jog up the learning curve before trying
to parse binary files.  (I also know that a bunch of ID3 editing programs
already exist.  I just think it'd be a good learning exercise.)

Another thing I want to do is write short shell-like scripts for my Windows
machine, e.g., copy and move or rename files whose size fulfills some
criteria or whose name matches some regexp, etc.  One of the reasons I
decided to play with Python was that I thought it could do these
scripting-like things; the first sentence on the back of "Learning Python"
refers to its suitability for "quick scripts."  However, I haven't seen
anything in the book's TOC or index on shell-like scripts, and a cursory
scan of the info at www.python.org didn't show any examples of things like
manipulating the underlying file system in a shell-script like manner.  So
here's my question: will Python let me do that?  I'm not asking about how
powerful the language is -- I know I can do anything with it.  But suppose
I want to rename files matching foo.* to be bar.*.  Ideally, I'd like to be
able to say something like this:

  rename foo.* bar.*

Will Python let me do that kind of thing?  If so, great.  If not, that's
okay, too.  At this point, I'm just trying to set my expectations
correctly.

Thanks,

Scott



More information about the Python-list mailing list