windows - Dirrectory name invalid -
the following code gives me weirdest errors have seen in long time. gives reference /*.*
when not using that? code:
t_src = src.get() t_dst = dst.get() print t_src try: item in os.listdir(t_src): print item s = os.path.abspath(os.path.join(t_src,item)) d = os.path.abspath(os.path.join(t_dst, item)) filename in os.listdir(s): try: if os.path.isfile(filename): print filename elif os.path.isdir(filename): print "possible dirrectory" print filename #shutil.copytree(filename, d) except: print "unexpected error:", traceback.format_exc() except: print "unexpected error:", traceback.format_exc()
the error:
c:\windows\system32\cmd.exe /c python copydir.py as.txt unexpected error: traceback (most recent call last): file "copydir.py", line 46, in copyfiles filename in os.listdir(s): windowserror: [error 267] directory name invalid: 'c:\\users\\jg \\desktop\\hello world\\as.txt/*.*'
the src.get()
comes tkinter, using gui. no problem. t_src
yields following example
c:/users/jg/desktop/hello world
the main goal output of files in folder , changes between two, have identical files etc. can see file structure producing isn't correct.
i using windows python 2.7.5 along text editor vim (which brilliant).
the item
file name - giving file name os.listdir
result in error getting. ratify problem use 'os.walk(t_src)'
Comments
Post a Comment