import os, shutil
from time import sleep
def dir_list(dir_name):
fileList
= []
for file in os.listdir(dir_name):
dirfile
= os.path.join(dir_name,
file)
if os.path.isfile(dirfile):
fileList.append(dirfile)
return fileList
if __name__ == '__main__':
dirNameS
= (os.path.join('C:\\', '
dirNameT
= (os.path.join('C:\\', 'target_directory'))
fileList
= dir_list(dirNameS)
"""
for f in fileList:
print f, os.path.getsize(f), os.path.getmtime(f)
print
"""
while True:
try:
for f in os.listdir('D:\\'):
print
f
print
sleep(5)
except:
break
# Untested
# You could
test whether the file to be copied has a different size or a later date
# copy the file f to file or directory
'dirNameT'
# shutil.copy(f, dirNameT)