0

I am new to python. Infact started yesterday and feeling out of place.
I need to write a program which would transfer files under one folder
structure (there are sub folders) to a single folder. I was going through COPYTREE in shutil. But some how I am not able to put into single folder. I am sure its matter of few commands. It
would be even more great if I could get some sample code with instructions

Thanks
Lalit

5
Contributors
4
Replies
5
Views
10 Years
Discussion Span
Last Post by jrcagle
0

os.path.walk has a callback function. Note this is untested code. Now that you know what to look for it should be fairly easy to find examples.

import os
def processDirectory ( args, dirname, filenames ):
   print 'Directory',dirname
   for filename in filenames:
      print '     File',filename 
#                                      
top_level_dir = "/usr/local"
os.path.walk(top_level_dir, processDirectory, None )
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.