[Tutor] working with os module

Deirdre Saoirse deirdre@deirdre.net
Wed, 25 Oct 2000 14:37:33 -0700 (PDT)


On Wed, 25 Oct 2000, Dwain Hargrave wrote:

> If I have a range of directories named "log1" through "log15" in a
> UNIX environment.
> 
> I want to cd to the the log1 directory to work with some files and add
> another sub-directory, then cd to log2...

You can have it move directories without actually using cd (unlike, say,
php).

> How can this be accomplished.  This is the train of thought I was
> going.  I'm very new to python.  Resisting the urge by my peers to use
> Perl.
> 
> #! /usr/bin/python
> 
> import sys, os
> 
> x = 0
> 
> for x in range(1,16):
>   if x < 16:
>     os.chdir("/fake/structure/log")
>     os.mkdir("archive")

      s = Added /fake/structure/log" + x
      print s

>     print "Added /fake/structure/log", x   <-- side question how would I
> have it move to the left one space

-- 
_Deirdre   *   http://www.sfknit.org   *   http://www.deirdre.net
"You had thesaurus flakes for breakfast again, didn't you?"
                                                 -- Eric Williams