Pyton:script to search and copy files recursively from directories

import os
import glob,shutil
os.chdir(“f:\docs\Foldername”)
print os.getcwd()
destdir = “F:\docs\Foldername”
for f in os.listdir(destdir):
finalpath=os.path.join(destdir, f)
if os.path.isdir(finalpath):
os.chdir(finalpath)
copypath=”*.wmv”
print os.getcwd()
os.system (“xcopy /s %s %s” % (copypath, destdir))
##for mov in glob.glob(finalpath+”\*.wmv”):
##shutil.copy(mov, destdir)

In

Leave a Reply

Your email address will not be published. Required fields are marked *