Create a Dated Folder with Bash
One command that creates a folder stamped with today's date. No more folders called "project-final-v3-REAL". Your filesystem stays sorted, your backups stay organized, and you always know exactly when you made it.
The One-Liner
Run this directly in your terminal — no script file needed.
mkdir "$(date +%Y-%m-%d)_project"
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.
Date Format Options
Variations
Create and immediately cd into it
DIR="$(date +%Y-%m-%d)_project" mkdir "$DIR" && cd "$DIR"
Create with a custom name after the date
mkdir "$(date +%Y-%m-%d)_client-meeting" mkdir "$(date +%Y-%m-%d)_deployment" mkdir "$(date +%Y-%m-%d)_backup"
Create a dated folder inside a target directory
mkdir -p ~/projects/"$(date +%Y-%m-%d)_new-feature"
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
#!/bin/bash # Create a dated folder with an optional name # USAGE: ./mkdate.sh [optional-name] # EXAMPLE: ./mkdate.sh deployment → creates 2026-05-03_deployment DATE=$(date +%Y-%m-%d) NAME="${1:-folder}" # ← uses "folder" if no argument given FULL="${DATE}_${NAME}" mkdir -p "$FULL" echo "✓ Created: $FULL" cd "$FULL"
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:
#!/bin/bash SOURCE="/home/user/documents" BACKUP_ROOT="/backup" DATE=$(date +%Y-%m-%d_%H-%M) DEST="$BACKUP_ROOT/$DATE" mkdir -p "$DEST" cp -r "$SOURCE" "$DEST" echo "✓ Backed up to: $DEST"
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 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.
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.