I am processing data and it is required to have same name of outputs [standard names] for different geographical regions. Therefore it is necessary to save outputs in different folders each time. Is there a way to create a folder with different name each time when i run script?


1 Answer 1


I'd recommend using the built in date module of python instead of random numbers. You won't have to worry about values being repeated, and the date tells you more about the file than any random number can.

Here's the Codecademy course for the Python date module -- it should have you up and running in no time.

from datetime import datetime

now = datetime.now()
day = now.day
month = now.month
year = now.year

print str(day) + "_" + str(month) +"_"+str(year)
  • Thanks. Very good link about date module. I added time to differentiate all folders.
    – Ibe
    Nov 1, 2012 at 12:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.