files,folders,paths

ecu_jon hayesjdno3 at yahoo.com
Mon Feb 14 04:06:59 EST 2011


i think i got it. my dirlist wasn't the right way to go, i needed to
iterate thu what oswalk was giving me in dirs, and files. not
bruteforce strip to a string. i have been starting at an early version
and a later version for the last 4 hours or so, and i think i have it
this only handles the folders. i wanted to try out the logic before i
doubled up and parsed files too. substitute this in for the backup
function. and for now the source and destination functions are in this
to. ill clean it up once i test it more.
backupdir = os.path.join(homedir, "backup")
remotedir = os.path.join(homedir, "backup2")
weekstr = "week"+str(week)
remotedirweek = os.path.join(remotedir, weekstr)
print
'################################################################'
for (path, dirs, files) in os.walk(backupdir):
    print "current path is : ",path
    print "current dir is : ",dirs
    print "current files are: ",files
    for fname in dirs:
        os.chdir(path)
        leftover = os.getcwd().replace(backupdir, '')
        print "leftover is:",leftover
        print "remotedirweek is:",remotedirweek
        currentdir1 = remotedirweek+leftover
        if not os.path.isdir(currentdir1):
            print "currentdir1:",currentdir1
            print "i should copy teh
folderz",os.path.join(currentdir1,fname)
 
shutil.copytree(os.getcwd(),os.path.join(currentdir1,fname))





More information about the Python-list mailing list