I wrote a little program that replaces all files called 'abcde' with the file in the directory from which you riun the program.  However it does not find them (there is another one).
What have I done wrong :-
#this program copies the file x to all other places in the directory.
#however it does not go to the right places
def getfiles(file1,file2,top):
    for root, dirs, files in os.walk(top):
        for name in dirs:
            for name in files:
        if name == file1:
            shutil.copy(file2,name)
                    print "copied one file"
     
import os
import shutil
#main
top = '/home'
a = os.getcwd()
filename = 'abcde'
file1 = filename
file2 = a+'/'+filename
getfiles(file1, file2,top)
print "finished"



To help you stay safe and secure online, we've developed the all new Yahoo! Security Centre.
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to