Skip to content

Instantly share code, notes, and snippets.

@mattions
Created May 4, 2010 09:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattions/389196 to your computer and use it in GitHub Desktop.
Save mattions/389196 to your computer and use it in GitHub Desktop.
def create_new_dir(self, prefix="./", root="Sims"):
"""
Create the directory where to put the simulation
"""
self.dirRoot = os.path.join(prefix, root)
today = datetime.date.today()
free = False
index = 0
dirDate = today.strftime("%d-%m-%Y")
dirComp = os.path.join(self.dirRoot, dirDate)
dir = os.path.join(dirComp, "Sim_" + str(index))
while not free :
if os.path.exists(dir):
index = index + 1
simNum = "Sim_" + str(index)
dir = os.path.join(dirComp, simNum )
else:
free = True
os.makedirs(dir)
return dir
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment