How should I write a path when a folder name contains spaces?
Quick answer
Quote the complete path value when passing it to a command. For example, in Bash use cat "/home/alex/Project Files/notes.txt"; in PowerShell use Get-Item -LiteralPath 'C:\Work\Project Files\notes.txt'. You can also escape spaces: Bash uses a backslash, while PowerShell uses a backtick for parameter values. These are different shell conventions, so use the form for the shell you are typing in [S1][S2].
The question, the details, the next step.
A practical checklist
Identify whether you are typing in Bash or PowerShell.
Quote the complete path value, including the spaced folder and filename.
If escaping spaces, use Bash backslashes or PowerShell backticks in the matching shell.
Check the path spelling if the command does not find the location.
Consult the command’s help if it still does not accept the path.
A few more useful answers
Can I use a backslash before a space in PowerShell?
The cited PowerShell parameter guidance specifies the backtick as the escape character for spaces, not Bash’s backslash convention [S2]. Use quotes or the PowerShell-specific form.
Do the quotes become part of the folder name?
In these examples, the quotes mark the path value supplied to the shell; they are not presented as characters in the folder name. Whether a particular path exists is a separate matter.
Does quoting guarantee that every command will accept the path?
No. Quoting addresses how the shell treats spaces. The cited PowerShell guidance does not settle how every native program parses arguments [S2], so check the command’s help if needed.
Sources
References used for this guide.
- [S1] Bash Reference Manual: Quoting gnu.org · Checked
- [S2] PowerShell about_Parameters learn.microsoft.com · Checked
