ytdlp.org
On this page

Workflow guide

How to use output templates in yt-dlp

If your downloads are turning into a pile of badly named files, output templates are the fix. The -o flag takes a template string with %(field)s placeholders that yt-dlp fills in per video, so filenames and folders stay predictable no matter how many URLs you throw at it.

Quick answer

yt-dlp -o "%(title)s.%(ext)s" "URL"

That is the basic pattern: tell yt-dlp exactly how to name the final file. Always keep %(ext)s at the end so the extension matches the format that actually gets written.

The fields you will actually use

The full list runs to hundreds of fields (yt-dlp --help under "OUTPUT TEMPLATE" has all of them). These are the handful that cover almost every real naming task:

FieldWhat it fills in
%(title)sVideo title
%(id)sVideo ID (unique, safe, never changes)
%(ext)sFile extension - always include this
%(uploader)sChannel or uploader name
%(upload_date)sUpload date as YYYYMMDD
%(resolution)se.g. 1920x1080
%(duration)sLength in seconds
%(playlist_title)sPlaylist name (empty for single videos)
%(playlist_index)sPosition in the playlist
%(autonumber)sCounter that increments across the whole run

Organize into folders

A / in the template becomes a folder. yt-dlp creates the directories for you.

yt-dlp -o "%(uploader)s/%(title)s.%(ext)s" "URL"

Instead of everything landing in one folder, downloads are grouped by source automatically.

Keep playlists in order with padded numbers

Any numeric field takes C-style padding, so %(playlist_index)03d gives 001, 002, … so files sort correctly instead of 1, 10, 11, 2.

yt-dlp -o "%(playlist_title)s/%(playlist_index)03d - %(title)s.%(ext)s" "PLAYLIST_URL"

For an arbitrary list of URLs that is not a playlist, use %(autonumber)03d instead - it counts across the whole run regardless of source.

Reformat dates

%(upload_date)s gives you a bare 20141110. Pass a strftime format after a > to reshape it:

yt-dlp -o "%(upload_date>%Y-%m-%d)s - %(title)s.%(ext)s" "URL"
# -> 2014-11-10 - Big Buck Bunny.mp4

Handle missing fields

Not every video has every field. By default a missing field becomes NA. Supply your own fallback with |:

yt-dlp -o "%(uploader|Unknown)s/%(title)s.%(ext)s" "URL"

Videos with no uploader land in an Unknown/ folder instead of NA/.

Safe filenames for other systems

Titles contain spaces, emoji and characters that break on other filesystems. If the files will move to Windows, a NAS, or a script that hates spaces, restrict them:

yt-dlp --restrict-filenames -o "%(title)s.%(ext)s" "URL"
# Big_Buck_Bunny_60fps_4K.mp4

Use --windows-filenames if you only need Windows compatibility, and --trim-filenames N to cap long titles. --trim-filenames counts characters, so for titles in non-Latin scripts cut by bytes instead (%(title).150B); Fix "File name too long" explains why.

Preview the filename before you download

You do not have to download anything to check whether a template does what you think. Ask yt-dlp to print the final path it would write:

yt-dlp --simulate --print filename \
  -o "%(uploader)s/%(upload_date>%Y)s - %(title)s.%(ext)s" "URL"

This is the fastest way to catch a mistake before you run it across a few hundred URLs.

Why this matters

Output templates are the bridge between one-off downloading and a repeatable workflow. If you ever rerun commands, work with playlists, or care where files land, this is a high-leverage habit. It also pairs directly with the download archive in batch jobs - consistent names make deduping and re-runs trivial.

Common output template mistakes

  • dropping %(ext)s, so the file has no usable extension
  • using a flat filename pattern for playlist downloads, so order is lost
  • forgetting padding, so files sort 1, 10, 11, 2 instead of 001, 002, 003
  • not adding a |fallback for fields that are sometimes missing
  • running the full batch before previewing one filename with --print filename

Delivery

Want files delivered clean, not cleaned up after?

Paste a link to see the structured metadata a media-import API returns before delivery to S3 or a webhook.

Building this into an app? See the API your backend calls instead