The One-Liner
Run this directly in your terminal — no script file needed.
What this creates
Running this today creates a folder called 2026-05-03_project. The $() syntax runs the date command and drops the result directly into the folder name. The +%Y-%m-%d format gives you year-month-day — which sorts correctly in every file manager.
Step-by-Step Setup
Step 1 — Run the one-liner directly in your terminal
No script file required. Open any terminal and run:
Replace _project with any label you want — _backup, _deployment, _client-meeting. The date prefix is added automatically.
Step 2 — Verify the folder was created
You should see the new folder listed. It sorts immediately to the correct chronological position alongside any other dated folders in the same directory.
Step 3 — Use the script version for repeat runs
When you need dated folders regularly (daily backups, weekly deploys, client deliverables), save the script version so you can add a custom label each time:
Paste the script variation from the Variations section below. Save with Ctrl+X → Y → Enter, then make it executable:
Run it with any label:
Step 4 — Add it as a permanent alias
This is what turns a one-liner into a daily habit. Add the alias to your shell config:
Paste at the bottom:
Save, then activate immediately without reopening the terminal:
Now type mkdate from anywhere to create and enter a new dated folder in seconds.
Using zsh?
Add the alias to ~/.zshrc instead, then run source ~/.zshrc. The alias syntax is identical — only the file changes.
Date Format Options
date +%Y-%m-%d 2026-05-03 Best for general use — sorts correctly
date +%Y-%m-%d_%H-%M 2026-05-03_14-32 Includes time — good for multiple per day
date +%Y%m%d 20260503 Compact — good for short names
date +%b-%d-%Y May-03-2026 Human readable — does not sort well
Variations
Create and immediately cd into it
Create with a custom name after the date
Create a dated folder inside a target directory
The -p flag creates any missing parent directories. If ~/projects/ doesn't exist yet, it gets created automatically.
Script version — reusable with a custom name argument
� Add it as an alias
Add this to your ~/.bashrc to create dated folders from anywhere with one command:
alias mkdate='mkdir "$(date +%Y-%m-%d)_project" && cd "$(date +%Y-%m-%d)_project"'
Then run source ~/.bashrc and type mkdate whenever you need a new timestamped working folder.
Organize daily backups automatically
Combine dated folders with your backup script to organize every backup into its own timestamped directory:
Understanding the date Command
| Format code | What it produces | Example |
|---|---|---|
| %Y | 4-digit year | 2026 |
| %m | 2-digit month (01–12) | 05 |
| %d | 2-digit day (01–31) | 03 |
| %H | Hour in 24h format (00–23) | 14 |
| %M | Minutes (00–59) | 32 |
| %S | Seconds (00–59) | 07 |
| %b | Abbreviated month name | May |
| %A | Full weekday name | Sunday |
Always quote your folder names
Always wrap dated folder names in quotes: mkdir "$(date +%Y-%m-%d)_my project". Without quotes, spaces in the name break the command into multiple arguments. The "$()" pattern handles this correctly.
Common Mistakes
Spaces in folder names break without quotes
mkdir $(date +%Y-%m-%d)_my project creates TWO items: a folder and a broken argument. Always wrap in double quotes: mkdir "$(date +%Y-%m-%d)_my project"
Date format that doesn't sort correctly
Using MM-DD-YYYY (like 05-13-2026) means folders sort by month, not chronologically. Always use YYYY-MM-DD (ISO 8601) — it sorts correctly in every file manager and ls output.
The alias doesn't persist after reboot
Adding an alias in the terminal only lasts for that session. You must add it to ~/.bashrc (or ~/.zshrc) AND run source ~/.bashrc for it to survive a reboot.
Get $200 Free →
View Hosting Plans →
Frequently Asked Questions
How do I create a folder with today's date in bash?
Run: mkdir "$(date +%Y-%m-%d)_project" — this creates a folder like 2026-05-03_project. The $(date +%Y-%m-%d) part runs the date command and inserts the result directly into the folder name.
How do I add a timestamp to a folder name in Linux?
Use date +%Y-%m-%d_%H-%M inside $(): mkdir "folder_$(date +%Y-%m-%d_%H-%M)". This gives you both the date and time in the name, useful when creating multiple folders on the same day.
What date format is best for folder names?
Use ISO 8601 format: YYYY-MM-DD. This sorts correctly in every file manager because the most significant unit (year) comes first. Formats like MM-DD-YYYY sort incorrectly by month rather than year.
Try the Generator → Browse All Tools