Paths
In Windows, the root (or utmost top-level) of your file system is a drive. In most cases, this will be the C
drive, represented as c:\
. Usually all your system files and data are on your C drive.
If you plug in a USB drive you'll will have additional drives which you can move to.
Normally, you'll be working on files within your user directory, which will be something like c:\Users\alice
Each file and directory has a unique path. The path is made up of the location within the file system tree as well as the name of the file or directory. Eg, my music directory might have the name music
, and be located at c:\Users\alice
, therefore have the absolute path of c:\Users\alice\music
Tips
- When you are working with directories in a graphical user interface, they will likely be referred to as a folder. Same thing, different name and representation.
- If you have a file or directory selected in Explorer, right-click on it and select Properties to see its path.
- Drag and drop a file or folder from Explorer into the command prompt to insert its full path.
- As you change directory, type the first letter of a path and press the TAB button on your keyboard. This allows you to 'tab complete' the path - a way of avoiding typing and also to probe out a path name
Relative paths
Any path that doesn't start with a forward slash is a relative path, meaning that its actual location depends on where you are when you refer to it. Relative paths are essential because otherwise we'd always have to type absolute (or full paths. Note that %HOMEPATH%
points to your home directory's absolute path.
For example, in my home directory, let's say I have documents, music, and photos subdirectories. If am at my home directory, I can type cd music
to change into the music subdirectory (so I will be at %HOMEPATH%\music
). When I use the relative path 'music' as part of cd music
, the system needs to resolve it to an absolute path. In this case, because there is a subdirectory called 'music' in our current directory, it knows what we mean by that relative path.
If the system can't resolve a relative path, you'll get an error message along the lines of 'The system cannot find the path specified.'.
You can traverse as many levels down the file system tree as you like: cd %HOMEPATH%\music\r\radiohead\amnesiac
You'll also want to go 'up' the file system tree, to shift your location to the parent directory of the directory you are in. You can use the special reference ..
for this. ..
always means 'up one level from the current path reference'.
For example, if we're deep down in our music:
C:\Users\alice\music\r\radiohead\amnesiac> cd ..
C:\Users\alice\music\r\radiohead> _
You can use several of these references to jump multiple levels up:
C:\Users\alice\music\r\radiohead\amnesiac> cd ..\..\..\
C:\Users\alice\music\> _