Re: [Tutor] Move files to a new directory with matching folder names

2014-05-27 Thread questions anon
Thanks all, I got it to work using: import os import shutil destination_prefix="/Data/test/" source_prefix="/Data/test1/" for year in range(2011, 2013): year = str(year) for month in range(1, 13): # convert to a string with leading 0 if needed month = "%02d" % month source = os.path.jo

Re: [Tutor] Move files to a new directory with matching folder names

2014-05-22 Thread Dave Angel
questions anon Wrote in message: > Please use text mail to post, as html has a number of problems. In your current message, indentation is lost. Also don't top-post in this forum. Any selective quoting of previous context should precede your comments. Your logic presently tries to copy a d

Re: [Tutor] Move files to a new directory with matching folder names

2014-05-21 Thread questions anon
Thank you for your response. I have created some sample folders and tried your method but I receive an error: IOError: [Errno 21] Is a directory: '/Data/test1/2011/01' The script I use is: destination_prefix="/Data/test/" source_prefix="/Data/test1/" for year in range(2011, 2012): year = str(

Re: [Tutor] Move files to a new directory with matching folder names

2014-05-21 Thread Steven D'Aprano
On Thu, May 22, 2014 at 10:25:27AM +1000, questions anon wrote: > 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 (s

Re: [Tutor] Move files to a new directory with matching folder names

2014-05-21 Thread Danny Yoo
On Wed, May 21, 2014 at 5:25 PM, questions anon wrote: > 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

[Tutor] Move files to a new directory with matching folder names

2014-05-21 Thread questions anon
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/0