Learn Dash Code
AboutContact
Mar 16, 2022

Command Line Interface (CLI)

I was thinking about what to write about today, as I was organizing my music files, and came up with an idea of how to do things easier than I was doing them. I had a bunch of song files, some in folders, and some just loose in my music folder. I wanted to put all the songs of each artist in that artist’s folder. So, what did I do? Probably what you would do – right click in the Music folder, select New -> Folder, right? Then name the folder, and drag the songs by that artist into that folder. Simple enough. But very time consuming.

What if there were an easier way to do such a simple thing? Well, there is. Use the command line interface, or terminal, or command prompt, to make things really easy. The CLI is used a lot by programmers, and it is a good thing to learn when you’re first learning to code (or before). This tutorial is for windows. If you have a Mac, the commands may be different, but the idea is the same.

Click on the search icon in your windows toolbar. Type “cmd prompt” enter. A terminal window will appear, like so:

cmd_prmpt-1.png

I was working in my music folder, which already existed; but for our purposes, let’s create a new music folder on the desktop. To get to the desktop, enter “cd desktop” without the quotes. The cd stands for change directory, and we want to create the music folder on the desktop in this case.

cd_desktop-1.png

Okay, we’ve now moved to the desktop. Now, type “mkdir music”, again without the quotes, then hit enter. Mkdir stands for make directory, and the folder we want to create is music.

music_folder_create.png

Notice that you don’t see the music folder in the terminal, because you are still on the desktop. If you navigate to your desktop, you will see a folder named music, that you just created. Pretty cool, huh? But it gets better. You can create more than one folder at a time, with the same mkdir command. Say you have several artists, which you probably do, and want to make a folder for each one. After you cd into the music folder (cd music), just type mkdir Sting “Phil Collins” Halsey “Ellie Holcomb” “Celtic Woman” Pink Prince “Gwen Stefani” “Maroon 5” Cher and hit enter. Voila! You just created 10 folders with one command, and learned a valuable coding skill! (Note that if the artist’s name contains a space, wrap it in double quotes).

Bill

Bill

Bill is a mostly self-taught developer, but also has a Full Stack Web Development certificate from the University of Arizona (2020).

Leave a Reply

Related Posts

Categories

Copyright © 2022 Learn Dash Code