ChatGPT (model unspecified)· OpenAI
ShareLM (browser-extension contributions)
write me in python code to generate an output dir name, that is based on the current…
- User
write me in python code to generate an output dir name, that is based on the current time stamp
- Assistant
Here’s a simple Python snippet that generates an output directory name based on the current timestamp: pythonCopy codeimport os from datetime import datetime
Generate timestamp-based directory name
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S") output_dir = f"output_{timestamp}"
Create the directory
os.makedirs(output_dir, exist_ok=True)
print(f"Created directory: {output_dir}")
This will create directories like: nginxCopy codeoutput_20250828_103522
Do you want the directory name to be just the timestamp (e.g., 20250828_103522) or always prefixed with "output_"?