Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialvsiddharthverma
3,182 PointsHow to find the specific files and export them to another directory?
Anybody can help me modify the code that I am trying to find the specific files and export them to another directory?
import os
import shutil
dst = r"D:\Survey_Home\DestTest"
src = r"D:\Survey_Home\3000pointsTOM_PDF"
for root, dirs, files in os.walk("D:\Survey_Home"):
for file in files:
if file.endswith(".pdf"):
print file
## src = os.path.join(root, file)
## print src
src_files = os.listdir(src)
print src_files
for file_name in src_files:
full_file_name = os.path.join(src, file_name)
if (os.path.isfile(full_file_name)):
shutil.copy(full_file_name, dst)
print 'copying pdf', src_files, 'to DestTest'
Steven Parker
231,271 PointsSteven Parker
231,271 PointsThis doesn't seem to be related to the "View Challenge" link. Is this a school homework assignment?