/errors/cmd/the-filename-directory-name-or-volume-label-syntax-is-incorrect
The filename, directory name, or volume label syntax is incorrect.
verified onenvironmentlocal · windows 10.0.26200 arm64 · GNU bash 5.3.15 (Git Bash)updated
- tool
- Command Prompt (cmd)
- exit code
- 1
- versions
- Windows 10, Windows 11, Windows Server 2016+
- os
- windows
The filename, directory name, or volume label syntax is incorrect. is Windows system error 123 (ERROR_INVALID_NAME). The path is not a valid Windows name at all, so Windows does not even look for it. File and folder names cannot contain < > : " / \ | ? *; a colon is only allowed after the drive letter. Print the expanded path and remove the character that does not belong.
Reproduce it
mkdir "build<1>" 2>&1
mkdir "logs|old" 2>&1
mkdir "logs-2026-10-21"
dir /b /ad logs*Output
The filename, directory name, or volume label syntax is incorrect. The filename, directory name, or volume label syntax is incorrect. logs-2026-10-21
Common sources of bad names
| Source | Example | Fix |
|---|---|---|
| %DATE% or %TIME% in a name | backup_%TIME%.zip contains colons | use a sortable date without separators, see below |
| Pasted from a browser or Explorer | file:///C:/data or a smart quote | paste plain text, remove the prefix |
| Variable with quotes, quoted again | set "DIR="C:\x"", then "%DIR%\out" | store values without quotes, quote at use |
| Wrong drive syntax | C;\data, C:data | C:\data |
A date-based name that is valid on every locale:
for /f %%d in ('powershell -NoProfile -Command "Get-Date -Date 2026-10-21 -Format yyyy-MM-dd"') do set "STAMP=%%d"
mkdir "backup-%STAMP%"
dir /b /ad backup-*Output
backup-2026-10-21
In a real script, drop -Date 2026-10-21 to use today's date. %DATE% itself is not portable: its format follows the user's regional settings and usually contains /.
Sources
Related pages
errors · cmdcmd: The system cannot find the path specified.cmd prints The system cannot find the path specified when a folder in the path is missing, a path with spaces is unquoted, or AutoRun names a bad path.errors · cmdcmd: The system cannot find the file specified.Windows error 2 means the folder exists but the file does not: a typo, a hidden extension like report.txt.txt, the wrong current folder or an unquoted path.cheat sheets · cmdcmd cheat sheet: files, variables, batch syntax and network commandsCommand Prompt cheat sheet: files and folders, variables and substrings, if and for in batch files, plus ipconfig, netstat -ano, tasklist and systeminfo.