Lalit Krishna schrieb: > Hi this is the code which I wrote till now. It is giving permission > denied error for sub folders of source directory. Does anyone have any > idea what is going wrong > > import os > import shutil > def copytreetosinglefolder(src, dst): > names = os.listdir(src) > if (os.path.isdir(dst)==False): > os.mkdir(dst) > for name in names: > srcname = os.path.join(src, name) > try: > shutil.copy2(srcname, dst) > except (IOError, os.error), why: > print "Can't copy %s to %s: %s" % (`srcname`, `dst`, str(why)) > > copytreetosinglefolder('c:\\src','d:\\dest')
Please use a mailer/news-agent that preserves whitespace on the beginning of the line, and make sure you don't use tabs but spaces to indent. Apart from that - why don't you use shutil.copytree? Regarding the error - are you allowed to copy, can you do it using the shell? Diez -- http://mail.python.org/mailman/listinfo/python-list