[Tutor] directory within directory
questions anon
questions.anon at gmail.com
Tue Aug 16 05:47:50 CEST 2011
I would like to open up a bunch of files within a folder within a folder and
then process them and output them in another location but with the same
folder structure. I seem to having trouble with the folder within folder
section.
I have a separate folder for each year and then within a year I have a
separate folder for each month but when I try to make a directory in a new
location it does not place the month folders within the year folders,
instead they are all places in the outputpath together
any help will be greatly appreciated
import os
inputpath=r'E:/temp_samples2/'
outputpath=r'E:/figureoutputs/'
for (path, dirs, files) in os.walk(inputpath):
for dir in dirs:
print path, dir
newfolders=outputpath+dir
if not os.path.exists(newfolders):
os.makedirs(newfolders)
print newfolders
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20110816/4d3acc1f/attachment.html>
More information about the Tutor
mailing list