beginner one-liner productivity

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.

Advertisement

The One-Liner

Run this directly in your terminal — no script file needed.

terminal
mkdir "$(date +%Y-%m-%d)_project"
✓ 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.

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

terminal
DIR="$(date +%Y-%m-%d)_project"
mkdir "$DIR" && cd "$DIR"

Create with a custom name after the date

terminal
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

terminal
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

mkdate.sh
#!/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 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:

backup-dated.sh
#!/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"
Advertisement

Understanding the date Command

Format codeWhat it producesExample
%Y4-digit year2026
%m2-digit month (01–12)05
%d2-digit day (01–31)03
%HHour in 24h format (00–23)14
%MMinutes (00–59)32
%SSeconds (00–59)07
%bAbbreviated month nameMay
%AFull weekday nameSunday
⚠ 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.

Organize your server projects the same way DigitalOcean droplets from $4/month — deploy bash scripts and keep your remote projects organized with the same techniques. New accounts get $200 free credit.
Get $200 Free →

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.

Related Snippets