A file path is the address of a file on your computer. See Windows and Mac paths side by side, absolute vs relative paths, how to copy a path, and try it safely.
A file path is a home address
A file path is the address of a file or folder on a computer. It names every folder on the way, from the start of the disk down to the file, so the computer knows exactly which file you mean. Here is one: C:\Users\you\Documents\my-project\hello.py.
The DayOneCode course uses a home address as the picture. A letter finds the right house because its address goes from big to small: country, town, street, house number. A path does the same: drive, then folders, then the file. And one wrong letter sends it to a different house, or to no house at all.
A folder is a drawer that can hold more drawers, so a path is really a list of drawers to open, one inside the next. On Windows, each backslash \ between two names means "go inside".
Do not mix this up with PATH in capitals. Microsoft’s PowerShell docs describe PATH as a list of folders the computer searches for programs. It holds many paths, but it is a setting, not one file’s address.
The parts of a path
Take the address of the cat picture in the practice terminal further down this page, C:\Users\you\Documents\my-project\images\cat.png, and read it from left to right:
| Part | In this path | What it means |
|---|---|---|
| Drive | C: | The disk the file lives on: a letter and a colon. |
| Separator | \ | The mark between two names. It means "go inside". |
| Folders | Users\you\Documents\my-project\images | The drawers to open, in order, biggest first. |
| File name | cat | The name of the file itself. |
| Ending | .png | The extension: the label on the lunchbox that says what is inside. Here, a picture. |
Microsoft’s rules for Windows paths agree: backslashes separate the parts, a file name can only be the last part, and a full stop separates a file’s name from its ending. A path that stops at a folder, such as C:\Users\you\Documents, is a folder’s address.
Side by side: Windows and Mac paths
A full Windows path starts with a drive letter and puts backslashes between names. A full Mac path starts with a forward slash and uses forward slashes throughout, as in Apple’s example /Applications/Utilities/Terminal.app. The same places on each, where you stands for your own user name:
| Where | Windows | Mac |
|---|---|---|
| Your home folder | C:\Users\you | /Users/you |
| Your Documents | C:\Users\you\Documents | /Users/you/Documents |
| A file in Documents | C:\Users\you\Documents\story.txt | /Users/you/Documents/story.txt |
| Between names | Backslash \ | Forward slash / |
| Short for "home" | ~ in PowerShell | ~ in Terminal |
Apple’s Terminal guide says the tilde ~ stands for your home folder, and that home folders sit in /Users. Microsoft’s PowerShell docs say the same for PowerShell commands: a ~ at the start of a path means your home folder. Some pages show /home/you as a Mac path, but on a Mac yours is /Users/you.
Capital letters differ too. Windows normally treats Notes.txt and notes.txt as the same name. Many other systems, including most web servers, do not, so a picture saved as MyImage.jpg may not load when a page asks for myimage.jpg. The safe habit everywhere is lowercase names.
Absolute and relative paths
An absolute path is the full address, from the very start: C:\Users\you\Documents\story.txt, or /Users/you/Documents/story.txt on a Mac. It works from anywhere, like a full address on an envelope.
A relative path is directions from where you are standing, like "the house two doors down". A terminal always stands in one folder, called the working directory, and a relative path starts from there. Two short signs, the same on Windows and Mac, do most of the work:
.(one dot) means this folder..\imagesis the images folder right here...(two dots) means the folder above, the one that holds this one...\story.txtis story.txt, one folder up...\..goes up two folders. From my-project,..\..\Pictures\beach.jpgclimbs to your home folder, then goes down into Pictures.
So, standing in C:\Users\you\Documents\my-project, the short images\cat.png and the long C:\Users\you\Documents\my-project\images\cat.png lead to the same picture. A relative path never begins with a drive letter and a backslash, or with / on a Mac. If it does, it is absolute.
Windows has one trap that catches experienced coders too. C:Projects\notes.txt, with no backslash after the colon, is not absolute: Windows reads it as relative to the current folder on drive C. Microsoft’s .NET docs call this mix-up a common source of bugs. Always put the backslash after the colon.
Try it: follow paths in a practice terminal
This practice terminal is a pretend Windows PowerShell on a pretend disk, so nothing you run here reaches your real files. It opens in C:\Users\you\Documents\my-project. Run the five commands in order:
pwdprints the absolute path of the folder you are standing in.dir imagespeeks inside a folder by a relative path, without moving.cat ..\story.txtreaches one folder up, into Documents, and shows the story saved there.dir ..\..\Desktopclimbs two folders, to your home folder, and lists the Desktop inside it.cd C:\Users\you\Pictureswalks to another folder by its absolute path. Watch the prompt change.
A pretend PowerShell on a pretend disk. Run the paths in order.
Now, standing in Pictures, run cat ..\story.txt once more. This time it fails: one folder up from Pictures is your home folder, and story.txt is not there. The path did not change, but the place you started from did. That is why a relative path can work in one folder and fail in another.
How to copy a path on Windows and Mac
On Windows 11 and 10
- Open the folder in File Explorer.
- Press Alt and D together to select the address bar at the top. It now holds the folder’s path as text, such as
C:\Users\you\Documents. - Press Ctrl and C to copy it. For a file inside, add a backslash and the file’s full name, ending included.
There is also a shortcut for a single file. Microsoft announced it on its Windows Insider blog in September 2021, in a test build of Windows 11: select a file or folder in File Explorer and press Ctrl, Shift and C to copy its path. If nothing happens on your computer, the address bar steps above still work.
On a Mac
- In Finder, choose View, then Show Path Bar. The folders that hold the item you selected appear near the bottom of the window.
- Control-click a folder in the path bar and choose Copy "folder" as Pathname, where the menu shows the folder’s real name.
- For a single file, right-click it in a Finder window, press and hold the Option key, then choose Copy "file" as Pathname.
Paths with spaces need quote marks
A space in a name is a classic trap. A terminal splits each command at its spaces, so cd My Projects looks like cd followed by two separate things. Microsoft’s PowerShell docs say that arguments with spaces, such as paths, must go inside quote marks. Apple’s Terminal guide gives similar advice for the Mac: quote marks around the path, or a backslash just before each space.
cd "C:\Users\you\My Projects" # works
cd C:\Users\you\My Projects # fails: the space splits itcd "/Users/you/My Projects"
cd /Users/you/My\ ProjectsThe easiest fix is to avoid spaces in the names you choose. MDN, Mozilla’s guide for web makers, suggests lowercase names with hyphens instead of spaces, which is why the course’s project folder is called my-project and not My Project.
Paths in HTML and Python
Web pages use paths to find their pictures, styles and other pages. In HTML you nearly always write a relative path, starting from the folder the page itself is in:
<img src="images/cat.png" alt="A cat">
<img src="../cat.png" alt="A cat, one folder up">MDN gives two rules worth learning by heart: use forward slashes in HTML, even when you build the site on Windows, and use ../ to go up a folder. Never point a page at C:\Users\you\...: that address is on your own disk, which the people visiting your site cannot see. The folder of a site builds a site folder like this.
Python uses paths when a program opens a file. Python’s docs say a path given to open() can be absolute or relative to the current working directory. That surprises people: a relative path starts from the folder the terminal stands in when you run the program, not always the folder the .py file is in. Forward slashes work in Python on Windows too, because Windows turns / into \ when it reads a path. The Python box on DayOneCode does not open files, so practise paths in the terminal above.
Names Windows will not allow
Windows keeps some characters and names for its own use, so a file or folder cannot be called them. From Microsoft’s list:
- Nine characters:
< > : " / \ | ? *. The colon and the backslash already have jobs in a path. - Device names such as CON, PRN, AUX, NUL, COM1 to COM9 and LPT1 to LPT9, even with an ending:
NUL.txtcounts as NUL. - A space or a full stop at the very end of a name. Microsoft says the Windows shell and user interface do not support such names, even where the disk could store them. A dot at the start, as in
.gitignore, is fine.
Length matters as well. Unless a deep Windows setting has been changed to lift it, a whole path is limited to 260 characters, so a file buried many folders deep can cause errors. Short, lowercase names in shallow folders avoid most of the problems on this page.
Paths are lesson 4 of the free Learn to code course, which needs no account and no install. Start with Paths: every file has an address, then move around by path in Walk around (cd). New to terminals? What is a terminal? explains the window these paths live in.
Try it on DayOneCode
- Paths: every file has an address
Lesson 4 of the free course: follow, build and write a file’s address, one folder at a time.
- Walk around (cd)
Walk into folders, back up with cd .., jump home with ~ and use whole paths, on a pretend disk.
- The folder of a site
Build my-site, a website folder with index.html, style.css and images, laid out the way real sites are.
- PowerShell cheat sheet
Every command the course teaches on one page, including pwd, dir and cd for moving around by path.
Questions and answers
What is an example of a file path?
On Windows, C:\Users\you\Documents\story.txt is a file path: the drive C:, then the folders Users, you and Documents, then the file story.txt, with a backslash between each part. The same file on a Mac would be /Users/you/Documents/story.txt, with forward slashes. In a web page, images/cat.png is a relative path to a picture in the images folder next to the page.
What is the difference between a file path and a directory?
A directory is another word for a folder: a drawer that holds files and other folders. A path is an address that leads to something. A directory path, such as C:\Users\you\Documents, stops at a folder. A file path goes one step further and ends with a file’s name and ending, such as C:\Users\you\Documents\story.txt. Every file path contains the path of the folder that holds it.
What is the difference between an absolute and a relative path?
An absolute path is the full address from the start, such as C:\Users\you\Documents\notes.txt, and it works from anywhere. A relative path gives directions from the folder you are in now, such as ..\notes.txt, where two dots mean one folder up. Relative paths are shorter and travel well with a project, but they break when you start from a different folder.
What is a file path in HTML?
In HTML, a file path tells the browser where to find a picture, a style sheet or another page, as in src="images/cat.png". It is usually relative to the folder the HTML file is in, and ../ means one folder up. Use forward slashes in HTML even on Windows. Keep names lowercase, because most web servers treat capital letters as different, and use hyphens instead of spaces.
How do I find the path of a file on Windows 11 or a Mac?
On Windows, open the folder in File Explorer, press Alt and D to select the address bar, then Ctrl and C to copy the folder’s path, and add a backslash and the file’s name. On a Mac, right-click the file in Finder, hold the Option key and choose Copy "file" as Pathname, where the menu shows the file’s real name.
Why does my file path not work?
Check four things. Is every name spelt exactly right, ending included? Does a path with a space in it have quote marks around it? Does a relative path start from the folder you think it does? Run pwd to check. On Windows, is there a backslash after the colon, C:\ and not just C:? Most broken paths fail one of these four checks.
Sources
The facts on this page were checked against these pages (14 November 2026):
- Microsoft Learn: Naming files, paths, and namespaces
- Microsoft Learn: File path formats on Windows systems
- Microsoft Learn: about_Parsing (PowerShell)
- Microsoft Support: Shortcuts in Windows (File Explorer)
- Windows Insider Blog: Windows 11 Insider Preview Build 22463
- Apple Support: Specify files and folders in Terminal on Mac
- Apple Support: Get file, folder, and disk information on Mac
- Microsoft Learn: about_Environment_Variables (PATH)
- MDN Web Docs: Dealing with files
- Python documentation: Built-in functions, open()
More from the blog
- What is a terminal? The plain answer, and your first three commands
A terminal is the window where you give your computer commands in words. Learn terminal vs shell vs command line, how to open one, and try three safe commands.
- Which Windows shell should a beginner learn: PowerShell or CMD?
PowerShell vs CMD, explained for beginners: what each Windows shell is, how to tell which one you are in, why pasted commands fail, and which one to learn first.
- What is an AI coding agent? What it does, and how to stay the boss
An AI coding agent reads your project, edits files and runs commands. See how it differs from a chatbot, how to stay safe, and who is old enough to use one.