questions anon wrote: > Thank you, that does create the directories in the new place but when I > process the data it does not put the outputs in the correct directory they > all end up in the last directory created. > Below is the code of what I am trying to do. > Any feedback will be greatly appreciated.
I think > for (path, dirs, files) in os.walk(inputpath): > for dir in dirs: > print dir > sourcepath=os.path.join(path,dir) > relativepath=os.path.relpath(sourcepath,inputpath) > newdir=os.path.join(outputpath,relativepath) the following two lines > if not os.path.exists(newdir): > os.makedirs(newdir) belong in the for-dirs-loop. plt.savefig() belongs into the for-ncfile loop and needs a path based on the path variable: > > for ncfile in files: > if ncfile[-3:]=='.nc': ... relativepath = os.path.relpath(path, inputpath) newdir = os.path.join(outputpath, relativepath) plt.savefig((os.path.join(newdir,'TSFC'+date_string+'UTC.png'))) All untested guesswork. I don't see how you ensure that you get a new figure for each *.nc file and am too lazy to consult the matplotlib documentation... _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor