OS Module 2: Command Line Expedition: Growing file trees and visualizing tree structure
Building on existing trees created by your peers.
This sequence will guide you through building onto an existing file tree created by another CCAC student (both online and in-person). You'll get to decompress the existing tree, add your own content and structure, and graft an entire tree into the tree you're editing. You'll have a newfound appreciation of the power of tree-based file structures by the end.
For the video watchers out there--here's a step-by-step screen cast of your isntructor completing the core steps in this tutorial. It is particularly helpful if you are having trouble navigating the command prompt and tree-creation steps in this guide.
Unpack and analyze another student's file tree, build on that tree, and repackage the tree for sharing
Navigate a directory structure using the Windows Command prompt and the cd dir and tree programs
Exercise 1: Download and unpack an existing student file tree
Exercise type: Navigation of an operating System's tools
- Open Windows File Explorer. You should have a directory("folder") dedicated to our CIT-100 online class in an accessible place, like in MyDocuments. If you don't please create one now. In your CIT-100 folder, create a new directory called "expandedFileTrees" where you'll download some existing trees and tinker with them.
- I've transferred all of the file trees ya'll uploaded last week to my running set of file trees from several other CIT-100 and CIT-115 classes. Open the shared directory -- we might call this our digital forest--with this link.
- Take a stroll through this digital forest and look for a tree that is related to a topic that interests you. Choose a file tree and download it into your "expandedFileTrees" folder by right clicking the file and selecting "Download".
- NOTE: You should be prompted with a window to choose the location to save the file. Navigate to the "expandedFileTrees" directory you created in step 1 and save it in there. (NOTE: If you don't get a window to choose a location, your browser is probably set to save them in a default location which is likely the Downloads folder in your home directory in Windows. You'll need to user copy and paste commands to transfer the file from Downloads to "expandedFileTrees"). You should now be able to navigate into windows explorer and see the folder CIT100 and expandedFileTrees and a compressed folder inside this.
- After you download them, the tree is stored in a compressed file, which we need to decompress to restore it to its tree-like structure. In file explorer, navigate into "expandedFileTrees" and right click your downloaded tree and select "Extract All" or "Extract Here". Navigate any dialog boxes that come after selecting this option. If given the option, please extract the tree into the same folder: "expandedFileTrees". NOTE that the screen clip below has a program called WinZip instead of "Extract All"--be a good computer user and find the program that makes the most sense on your system.
- You should now see actual directories--not just files with a .zip extension--that you can navigate and explore. Check out the way your tree builder organized their content. Traverse into the tree's leaves and open some of the media. Think: What could I add to this tree?
- We are now going to visualize the tree you downloaded using a program called--of all things--"tree" which shows how a directory structure is organized. To do this, open a program called Command Prompt" by clicking your Windows icon in the lower left of your screen.
- You'll see a black window with something like "C:\" at the top (see above) and a flashing cursor. Welcome to the "back-end" of the Windows operating system. This program allows you to navigate to and run programs using your keyboard and typing specific commands which this tool turns into requests for the operating system to do something, like change the directory the program is viewing.
- NOTE: You'll do this by typing the command cd followed by a space and then the name of the directory you want to go into--but it has to be one of the subdirectories of your current directory. Note that the line that the cursor is on lists your current directory. So look at this screen clip:
- Note that I typed "cd Documents" to change my working directory into the Documents folder. This was possible because Documents is a folder inside C:\Users\ericd\. It is possible that your command prompt does not start in the same directory. You will need to use the combination of cd followed by the directory name you want to go into to get to the proper place. There are bunches of youtube videos--try searching "changing folders windows command prompt" to see some.
- Now that I am in the cit100 directory, I can use cd again to move into my expandedFileTrees directory like this:
- Notice that I can always type the command "dir" to see what directories and files are in my current working directory. If you don't see a directory with the name you want to move into in this list, you can't use a cd command to get in there.
- If you need to "up" into a parent folder, use cd .. (two periods). Note that your current folder is displayed as your command prompt.
- Once you are in the "expandedFileTrees" directory inside the command prompt, simply issue the command "tree" and boom! You'll see a printout on your screen of all the subfolders in that sub-folder which will display the structure of your peer's file tree. Isn't that neat!?!!?
- Now that we can see the file tree we downloaded, We want to compare the original file tree with content that you'll add to the tree, including new subfolders within the categories that your peer student created. Open a blank word processing document (this tutorial uses MS Word) and adjust the following formatting options:
- Change the margins on the page to 0.5"
- Turn on the rulers tool so we can see what we're going to do next:
- Format the page to have two columns:
- Add a header at the top of column 1 by selecting Header 1 from the Home tab like this:
- You can now copy and paste the file tree that the command prompt's "tree" program created into the left column of the word processing document. Select text in the black command prompt window by selecting the text you want to copy (the entire tree) and then clicking "enter". This is a strange command. When you click enter, you'll notice the selection goes away and now that text is in your "clipboard" which allows you to paste that into the word processing document using control + v.
- Make sure to format the pasted text nicely, so it fits on one column of one page. See the sample image below of a nicely formatted page. You'll want to do this by changing the line spacing to single:
- Now that you have a before shot, expand the tree you're working with by adding sub-folders and some new content like you built your own tree. The goal here is to see the expanded structure, so adding sub-folders is the most important thing, and adding images and links is secondary. Because the tree program only lists folders, any files you add won't add to the structure, just content. This is me adding a folder in Mellisha's board games tree:
- Once you have added 5-10 new folders and some content in them, re-run the tree program in command prompt to visualize your expanded tree. With the following steps:
- Follow the same steps above that we used above to copy and paste the before tree to copy and paste the expanded tree into the right column of the word processing document. Format both columns so they match each other. To do this, start by moving to the top of the right column by adding something called a column break--which tells the word processor to stop adding text in the current column and move to the top of the next one:
- Now go back to your command prompt and issue the command "tree" again. It should be in the proper directory since it doesn't change itself.
- Select the updated tree like before, and paste it into the word processor. Select the tree and format it as single-spaced lines. Now add a header 1 to the top of the expanded tree with a name like "Expanded Tree".
- Highlight the changes in the expanded tree that you added so that future students can see how the tree has grown!
- Your completed document should look something like this:
- Save the word processing document into your "expandedFileTrees" folder. You can use a logical name like "expandedTree.docx".
- Now we want to export this document as a PDF and upload it to the shared tree directory in the cloud so others can see the trees which are adjusted. If you are using MS Word, click "file" >> export >> pdf. But don't name the file yet, since we have to be careful:
- When you go to save this file, we want to name the file in a way such that when others view the file tree list in the cloud, they see your tree visualization right next to the original file tree zipped folder--this way it's convenient to see you nice work! To do this, name the PDF file exactly the same way as the original .zip folder, but add the text "_expandedBy[your name][your special id#]" to the end of the file name (see the example). Make sure to keep the .pdf extension so the file is viewable by PDF viewers worldwide. The following screen show shows me splitting my window so I can see both the online directory and my save window so the names can match. The important thing is that the first word or two are the same--copying the other student's magic number isn't important.
- Finally, re-compress your expanded tree by navigating to the "expandedFileTree" directory, selecting the root folder of the tree, and right clicking that file >> Send to >> Compressed Folder.
- You'll be given a chance to rename the zipped folder, which you should edit to be exactly the same name as the original zipped folder with the text "_expandedBy[yourname][your special ID]" added to the end. Once again, this is so future students can see the original tree, the expanded tree, and the diagram PDF you created all grouped together in the shared directory in the cloud.
- With your PDF and expanded tree all ready to roll, open our shared cloud folder (linked above) and upload both the expanded tree zipped folder, and your PDF. Remember, we want to upload "Files" not folders
- Check to make sure your file naming worked by scrolling to the top of the share directory and right-clicking the file name header and selecting sort "A-Z" and check to make sure your files are there and exist right alongside the original files. You may have to reload the page after your upload to see the files. If they don't please rename the files as needed and re-upload. You can't delete from the share drive, so drop your teacher an email and list the folders that need to be deleted due to improper naming.
- GREAT! That was a lot of work, but worth it. Students for years to come will get to build even on your expanded tree, and we'll have a truly growing digital forest. And now you have lots of confidence in navigating folder structures, using the command line, and the file compression utilities in the Windows operating system.
Add content to the existing tree: Grow the tree!!
Tinker more with the Windows Command prompt
The command prompt that you used in the above learning sequence provides access to most basic file system operations that you've done so far in the graphical Windows Explorer program (clicking with the mouse instead of typing commands). The following steps will walk you through creating directories, files, and removing them using only the command line. Try it out! You'll feel like a whiz after, I promise!.
- Navigate to your expandedFileTress directory (or really, any other directory that you have write access to) and run the following commands that create a directory called testDir and then create a file called testfile.txt:
- Notice how the echo command works: we issue the command echo which is very simple: it takes whatever is passed into it (meaning any text that follows the command after the space) and sends it to the terminal screen. Try typing echo hereIAm. The > is a file redirect command which tells the command prompt program to take whatever the echo program outputs and send it to a file with the name testfile.txt.
- Let's verify that this command actually adjusted the file system by viewing the directory we just created and the file we created in the graphical Windows Explorer. You can right click the text file called testFile.txt and choose Open With >> notepad to see that we did indeed create a simple file with whatever text we sent into echo.
- Isn't that cool?! We can interact with the operating system using only our keyboard. For most of computer history, this is how commands were issued to the computer since they weren't powerful enough to cope with the graphical systems that we are so familiar with today.
- Now we can remove what we just created, cleaning up our workspace. Note that del command will delete anything you type, so be careful!
- We can verify that the delete worked by checking back in Windows Explorer and looking for the directory and file which was just there.
Page created on 15 Feb 2018 and last updated on 15 Feb 2018 and can be freely reproduced according to the site's content use agreement.