MCS 260 Fall 2021
Week 1 Discussion
A file is a named collection of data (e.g. a document). Files cannot contain other files.
A directory or folder is a named container for both files and directories.
Multiple files may share the same name. To specify a file, you also need to know what directory it is in.
A full path does this. It specifies the file name and all the directories containing it.
Example (Linux/OS X):
Consider the Windows example:
"C:" is the drive letter (specifies a storage device)
"\" is a separator (appears between directory names and file names)
"Users", "sramanujan", "Documents" are directories, each contained within the previous one
"letter.pdf" is the filename
Icons on the desktop are just files in a certain directory.
In Windows, the desktop directory for a user named "ddumas" is usually:
In OS X, it is usually:
In Linux, it is usually:
This file on professor Dumas's desktop:
Has full path:
So one way to run it in Powershell would be:
Terminal interfaces and some other programs have a notion of the current working directory.
There is a command to show the current directory in a terminal:
(print working directory)
Important: In a terminal, filenames without a full path are assumed to refer to files in the current directory.
In Powershell, this command will probably fail:
It only looks in the current directory for a file named "hello.py". If a file with that name exists but is in a different directory, it will not be found.
To fix this, you have two choices:
Move to another directory given by a full path:
Move to another directory that is contained in the current one (a subdirectory):
Move to the parent directory, i.e. the one that contains the current one:
We want to run hello.py, a script on the desktop.
In PowerShell, with absolute path:
PS C:\Users\ddumas> python C:\Users\ddumas\Desktop\hello.py Hello world
In PowerShell, first cd to Desktop, then run:
PS C:\Users\ddumas> cd Desktop PS C:\Users\ddumas\Desktop> python hello.py Hello world
In PowerShell, with relative path:
PS C:\Users\ddumas> python Desktop\hello.py Hello world
If you have a file open in Visual Studio Code, you can ask for its full path to be copied to the clipboard.
Right-click on the file name tab and select "Copy path".