Workshop: Media Types and File Sharing
This workshop will cover different types of files and media. We will look at audio, video and image files, and how they are made, learn how to convert between them and how to find them online. We will use the command line to make tiny media libraries, and share them with one another!
Intro: file formats
At the most basic level, information on computers is represented by strings of ones and zeroes. The ones and zeroes are grouped together into 'files' (containers for information), and those files arrive in a 'format'. To differentiate the ones and zeroes that make up an image, from those that make up text, audio or video files, computers need a lot of structuring information. You can think of a 'file format' as a set of standardised rules for how the computer should read and display the information it finds in a file, and how it should structure that information for files that can be read in the same way.
Many of the distinctions between different kinds of media file formats are based on mathematical differences about how information in them is compressed. For example, the difference between the audio formats .mp3, .wav and .ogg, or the image formats .jpg, .png and .bmp are mostly to do with how much space they take up on a computer. There are also political and legal differences -- for example, the differences between the the Microsoft Word Binary File Format (.doc), the Open Document Format (.odt), and the Open Office XML format (.docx) are that the first file format belongs to Microsoft, the second was explicitly intended to be an open standard, and the third became the standard interchange with heavy influence from Microsoft.
File formats are not naturally occurring phenomena -- there are large bureaucratic bodies dedicated to the design, development and standardisation of different file formats. Historically, there have been huge debates about file formats -- particularly around questions of proprietary file formats and licensing.
Recognising file formats
File names give you core information about the files themselves. The part you are interested in is the end, or extension. Normally the letters and numbers in a file's extension relate to a longer sequence of words that describe the process of formatting that file -- so ".pdf" stands for "portable document format", and ".jpeg" stands for "joint photographic experts group", the name of the organisation who came up with the standard for JPEG formatting.
Plain text file formats
A file is referred to as "plain text" if it can be represented just as characters (letters, numbers, punctuation, symbols), and not its graphical representation.
- Almost all code files are plain text (.py, .js, .c, .json)
- The .txt file format is plain text -- so are formats like .md and .html, which are called 'markup'
- There are some plain text data formats like .csv, which represent information like spreadsheets
Not all files which are about text are 'plain text' files! Word documents (.docx),
Binary file formats
Just because a file isn't written in plain text
The core point: all files on a computer are represented, at base, by a series of zeroes and ones.
Activity 1: Glitch a JPG
Demo: find, move, copy
Command line from last weeks' lesson.
Activity 2: Files Treasure Hunt
The find command
In pairs and threes, see if you can find the following kinds of files on your computers
Challenge -- if you feel confident, try using the find command!
Activity 3: Gallery/Mixtape
The move and copy commands
Challenge: try doing this using your command line
Writing a README
An important part of sharing files with other people is explaining what the files are for, what they contain, and how to read, use and open them. This is considered good practice in a lot of disciplines, but is particularly important when writing code, as the interaction of files can be complex. Within software development, there's a convention to title these files 'README' -- which functions as a command.
README files are always written in a plaintext format, so no special software is required to read them. Normally this is either a .txt ("text file") or .md ("markdown file").
Task: Write a short README file in txt format for your mixtape / gallery. Instruct the listener / viewer what software they should open the files in, and feel free to include artistic notes, thoughts, etc.
Tools and Further Reading
File Browser Commands
- on a Mac: ⌘ + shift + .
- on Windows: "View" > "Hidden Items"
Show path bar:
- on a Mac: "View" > "Show Path Bar"
- on Windows: shown by default
List of Command Line Commands
In this session, we are going to use the following commands:
command | name | meaning |
---|---|---|
mv a.txt b/ |
"move" | move the file "a.txt" into the folder "b" |
mv a/ b/ |
"move" | rename the folder called "a" to "b" |
mv a.txt b.txt |
"move" | rename the file "a.txt" to "b.txt" |
cp a.txt b/ |
"copy" | copy the file "a.txt" into the folder "b" |
cp "~/Downloads/c.mp3" ./ |
"copy" | copy the file "c.mp3" from "Downloads" into the current folder |
find . -name "*.txt" |
"find" | find all files ending in .txt inside the current folder |
Commands we learned last week:
command | name | meaning |
---|---|---|
pwd |
"print working directory" | print out a path to my current location |
ls |
"list" | list the files and folders in the current location |
cd |
"change directory" | move to a different folder |
cd .. |
"change directory" | move UP one folder |
cd ~ |
"change directory" | navigate to the Home directory |
touch file.txt |
"touch" | make a new, empty file called file.txt |
cat file.txt |
"concatenate" | print out the contents of a file called file.txt |
mkdir my-folder |
"make directory" | make a new folder called 'my-folder' |
echo "some text" |
"echo" | write out the text "some text" |
echo "some text" > file.txt |
"write" | overwrite the contents of file.txt with "some text" |
echo "some text" >> file.txt |
"append" | add the text "some text" to the end of file.txt |
Neat tricks:
- Type
cd
(cd and then a space), and then drag and drop the folder you want to navigate to onto the command line. Press enter and it will take you there - Use the Tab key to autocomplete folder and file paths
- Use the up and down arrow keys to find and select commands you already ran
- on a Mac: hold down the 'option' key to place your cursor anywhere on the command line
Watch out for:
- make sure you use spaces to separate between a command, and the thing you are using it on. For example,
cd..
won't work, butcd ..
will! - if you get a message that says 'command not found', double check that it's spelt right and that you used spaces in the correct place!
- for the same reason that spaces are used to separate out commands, they will cause issues if you use them in the names of files and folders! The best way to do this is to avoid it completely -- use a dash or underscore instead!