Hi all. I am new as can be to programming. I always heard a good way to learn to write was to find a project that I am interested in and start from there. So my ideal goal is to write a script that cleans up my downloads folder, ie moves .zips to the zip folder, pics to pics etc etc etc.
As you will be able to tell, I am not that far yet. I am still having problems getting the shutil.copy command to properly work; it keeps kicking out errors. I figured it was related to the path name as I am using a windows machine. So I tried to piece together some code using os.path commands etc etc.
Here is my code. I know this is an absolute mess extremely redundant and could probably be completed in two lines, but like I said.. I am completely green at this. Any help diagnosing my problem would be greatly appreciated.
import os
import shutil
curdir=os.getcwd()
print "This is the starting dir:", curdir
files= os.listdir(os.getcwd())
print "These are the files I want to copy:", files
os.chdir("updog")
dest=os.path.abspath(os.getcwd())
os.chdir(curdir)
print "This is the directory I want to copy to:",dest
print "This is where I am copying from:",curdir
shutil.copy(files, dest)
The errors I receive:
shutil.copy(files, dest)
File "C:\Python27\lib\shutil.py", line 115, in copy
dst = os.path.join(dst, os.path.basename(src))
File "C:\Python27\lib\ntpath.py", line 198, in basename
return split(p)[1]
File "C:\Python27\lib\ntpath.py", line 181, in split
return d + head, tail
TypeError: cannot concatenate 'str' and 'list' objects