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 trial

Python Object-Oriented Python (retired) Objects Create a Class with an Attribute

How to find files with specific extension and copy them to a directory

Anybody can help me how to modify this code to make it working?

mport 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)

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'

attribute.py

Steven Parker
Steven Parker
231,271 Points

This doesn't seem to be related to the "View Challenge" link. Is this a school homework assignment?

1 Answer

I got it working. Thank you!