how to touch a file

s99999999s2003 at yahoo.com s99999999s2003 at yahoo.com
Thu Apr 6 06:16:14 EDT 2006


hi

i have a dir that contains directories with names and spaces in between
example

rootdir
   | ----> ABC DEF A
   | ---> BDD SD N

I wanted to touch a file with the same name as the directories inside
each directory

rootdir
   | ----> ABC DEF A
                  |-------> ABC DEF A-dummy
   | ---> BDD SD N
                  |-------> BDD SD N-dummy

heres the code :
for d in os.walk(rootdir):
        (dirpath, dirnames, filenames) = d
        for dir in [dirpath]:
                if not os.path.exists( os.path.join(dir,"-dummy") ):
                        f = open( os.path.join(dir,"-dummy") ,
"w").write("")

but i got only "-dummy" as the filename in each directory

How can i deal with spaces in this case? or is there some wrong things
i do in the code?
thanks for any help.




More information about the Python-list mailing list