I have files contained separately in folders labelled by years and months
and I would like to copy them into another directory where they have
matching folder names of years and months.
I can do this for one folder at a time (see below) but I want it to be able
to go through all the folders (2002/01,2002/02.....2012/11,2012/12) and
copy files from one directory to another directory with matching subdir
names.
thanks

import os

import shutil

source="/Data/allclimatedata/2002/01"

destination="/Data/rainfall/2002/01"



for file in os.listdir(source):

path = os.path.join(source, file)

shutil.copy(path, destination)
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to