A computer’s filesystem is simply the system it uses to organize files into folders. If you understand where you are in that folder structure, and how to move from one folder to another, the filesystem becomes much less mysterious.
A file is an individual item such as a Python program, CSV file, image, PDF, or Word document. A folder is a container that can hold files and other folders. Be advised that the term directory is an exact synonym of folder which is used by many systems. You’ll often hear Stephen use the word “directory” in class: you can mentally substitute “folder” if you like.
Next, realize that you can look at the same filesystem in two different ways:
These are not two different filesystems. They are two different ways of looking at the same files and folders.
On Windows, the main program for viewing files and folders is called File Explorer.
You can open it in several ways:
File Explorer shows folders and files visually. You can double-click a folder to enter it and double-click a file to open it.
Windows gives each user an individual folder. It is normally located at:
C:\Users\YourName
For example, if your Windows username were filbert, your
user folder would normally be:
C:\Users\filbert
Inside your user folder are several common folders that Windows and other programs use automatically. The most important ones are usually:
Desktop
Documents
Downloads
Pictures
So, for example, your Downloads folder is normally:
C:\Users\YourName\Downloads
and your Documents folder is normally:
C:\Users\YourName\Documents
The backslash (\) separates one folder name from the
next in a Windows path.
Near the top of a File Explorer window is the address bar. It tells you which folder you are currently viewing.
For example, you might see something resembling:
This PC > Local Disk (C:) > Users > filbert > Downloads
That is the visual version of the path:
C:\Users\filbert\Downloads
You can click parts of the address bar to move upward to a containing folder.
A particularly useful trick is to click in the blank area of the address bar (or press Ctrl+L). The breadcrumb-style display will change into the actual full path as ordinary text. For example:
C:\Users\filbert\Downloads
You can then press Ctrl+C to copy that path and
paste it somewhere else. This is especially handy when you are looking
at the folder you want in File Explorer and need to give that same
folder to PowerShell. For example, after copying the path above, you
could type cd in PowerShell, paste the path, and press
Enter.
The left side of File Explorer also normally contains shortcuts to common locations such as Desktop, Documents, and Downloads.
When you download a file from a web browser, Windows browsers normally save it in your Downloads folder unless:
So if you download a file named:
paperclip_collection.csv
it will normally end up at:
C:\Users\YourName\Downloads\paperclip_collection.csv
To find it visually:
Many browsers also have a downloads button or downloads list. That can help you confirm the filename, but the file itself still lives somewhere in your filesystem.
Suppose you have a course folder here:
C:\Users\YourName\DATA419-labs
You can navigate there visually by opening:
C:
then:
Users
then your username, and finally:
DATA419-labs
You can also click the File Explorer address bar, type the complete path:
C:\Users\YourName\DATA419-labs
and press Enter.
Suppose this file is in Downloads:
C:\Users\YourName\Downloads\paperclip_collection.csv
and you want it in:
C:\Users\YourName\DATA419-labs
DATA419-labs.Now there are two copies of the file: one in Downloads and one in
DATA419-labs.
DATA419-labs.Now the file has been removed from Downloads and placed in
DATA419-labs.
You can also drag files from one folder to another with the mouse, although copy-and-paste or cut-and-paste is often easier to understand when you are first learning.
Windows also lets you work with the filesystem through PowerShell.
To open it:
PowerShell always has a current working folder. This is the folder that PowerShell is currently “inside.”
To see your current working folder, type:
pwdYou might see something like:
Path
----
C:\Users\filbert
This means PowerShell is currently looking at:
C:\Users\filbert
That is the same folder you could open visually in File Explorer.
In PowerShell, type:
lsThis displays the files and folders inside your current working folder.
For example, if pwd says:
C:\Users\filbert
then ls is showing the same contents that File Explorer
would show if its address bar were at:
C:\Users\filbert
Use cd, which means change directory.
Here, “directory” is simply another word for “folder.”
To go into Downloads:
cd DownloadsThen:
pwdshould show:
C:\Users\filbert\Downloads
To go back up one level:
cd ..The two dots mean “the folder that contains this folder.”
You can also change directly to a complete path:
cd C:\Users\filbert\DATA419-labsIf a folder name contains spaces, put the path in quotes:
cd "C:\Users\filbert\My Course Files"The most important idea is this:
The folder shown in File Explorer and the working folder in PowerShell are locations in the same filesystem.
For example, suppose File Explorer is showing:
C:\Users\filbert\DATA419-labs
If you want PowerShell to work in that same folder, use:
cd C:\Users\filbert\DATA419-labsThen confirm with:
pwdand view its contents with:
lsIf you create, copy, move, rename, or delete a file in File Explorer, that change is visible in PowerShell. If you change the filesystem using PowerShell, the change is visible in File Explorer.
They are two views of the same thing.
Suppose your instructor tells you to download data.csv
and place it in your DATA419-labs folder.
A normal workflow would be:
Download data.csv in your web browser.
Open File Explorer with Windows key + E.
Click Downloads.
Find data.csv.
Cut it with Ctrl+X.
Navigate to:
C:\Users\YourName\DATA419-labsPaste it with Ctrl+V.
Open PowerShell.
Change to the same folder:
cd C:\Users\YourName\DATA419-labsConfirm your location:
pwdConfirm that the file is there:
lsAt this point, File Explorer and PowerShell should both show that
data.csv is inside your DATA419-labs
folder.
On a Mac, the main program for viewing files and folders is called Finder.
Finder is normally always available. Its icon looks like a two-tone smiling face and is usually located at the left side of the Dock.
Click the Finder icon to open a Finder window.
Finder shows folders and files visually. You can double-click a folder to enter it and double-click a file to open it.
macOS gives each user an individual home folder. It is normally located at:
/Users/yourname
For example, if your macOS username were filbert, your
home folder would normally be:
/Users/filbert
Inside your home folder are several common folders that macOS and other programs use automatically. The most important ones are usually:
Desktop
Documents
Downloads
Pictures
So your Downloads folder is normally:
/Users/yourname/Downloads
and your Documents folder is normally:
/Users/yourname/Documents
The forward slash (/) separates one folder name from the
next in a macOS path.
Finder normally provides shortcuts to common folders such as Desktop, Documents, and Downloads in its sidebar.
To make Finder show the folder path more explicitly, choose:
View > Show Path Bar
The path bar appears near the bottom of the Finder window and shows where the current folder is located.
For example, if you are viewing your Downloads folder, its full path might be:
/Users/filbert/Downloads
You can also press:
Command+Shift+G
to open Go to Folder, then type a path directly.
For example:
/Users/filbert/DATA419-labs
and press Enter.
When you download a file from a web browser, macOS browsers normally save it in your Downloads folder unless:
So if you download:
paperclip_collection.csv
it will normally end up at:
/Users/yourname/Downloads/paperclip_collection.csv
To find it visually:
The browser may also show a downloads list, but the downloaded file itself is stored somewhere in your filesystem.
Suppose you have a course folder here:
/Users/yourname/DATA419-labs
You can navigate to it in Finder by first opening your home folder
and then opening DATA419-labs.
You can also press:
Command+Shift+G
enter:
/Users/yourname/DATA419-labs
and press Enter.
Suppose this file is in Downloads:
/Users/yourname/Downloads/paperclip_collection.csv
and you want it in:
/Users/yourname/DATA419-labs
DATA419-labs.Now there are two copies of the file.
Finder’s keyboard shortcut for moving is slightly different from Windows.
DATA419-labs.This moves the file to the new folder instead of leaving a copy behind.
You can also drag a file from one folder to another using the mouse or trackpad.
macOS also lets you work with the filesystem through Terminal.
One easy way to open Terminal is:
Terminal.Terminal always has a current working folder. This is the folder that Terminal is currently “inside.”
To see your current working folder, type:
pwdYou might see:
/Users/filbert
This means Terminal is currently working in your home folder.
That is the same folder that Finder can show visually.
In Terminal, type:
lsThis displays the files and folders inside your current working folder.
For example, if pwd says:
/Users/filbert
then ls is showing the same folder contents that Finder
would show when viewing:
/Users/filbert
Use cd, which means change directory. A
directory is simply a folder.
To go into Downloads:
cd DownloadsThen:
pwdshould show:
/Users/filbert/Downloads
To go back up one level:
cd ..The two dots mean “the folder that contains this folder.”
You can also change directly to a complete path:
cd /Users/filbert/DATA419-labsIf a folder name contains spaces, put the path in quotes:
cd "/Users/filbert/My Course Files"~On macOS, the symbol:
~
is a shortcut meaning “my home folder.”
So if your home folder is:
/Users/filbert
then these two commands refer to the same folder:
cd /Users/filbert/Downloadscd ~/DownloadsLikewise:
cd ~/DATA419-labsmeans “go to the DATA419-labs folder inside my home
folder.”
The most important idea is this:
The folder shown in Finder and the working folder in Terminal are locations in the same filesystem.
Suppose Finder is showing:
/Users/filbert/DATA419-labs
If you want Terminal to work in that same folder, use:
cd /Users/filbert/DATA419-labsor:
cd ~/DATA419-labsThen confirm with:
pwdand view its contents with:
lsIf you create, copy, move, rename, or delete a file in Finder, that change is visible in Terminal. If you make a change using Terminal, that change is visible in Finder.
They are two views of the same thing.
Suppose your instructor tells you to download data.csv
and place it in your DATA419-labs folder.
A normal workflow would be:
Download data.csv in your web browser.
Open Finder.
Click Downloads.
Find data.csv.
Copy it with Command+C.
Navigate to DATA419-labs.
Move the file there with Option+Command+V.
Open Terminal.
Change to the same folder:
cd ~/DATA419-labsConfirm your location:
pwdConfirm that the file is there:
lsAt this point, Finder and Terminal should both show that
data.csv is inside your DATA419-labs
folder.