checking the microphone and webcam

How to Create a Folder/Directory With the Mac Terminal

Why bother with the command line?

It’s certainly easy to copy and move files in the Finder, but there are a number of reasons why you might want to do this from the command line instead:

  • You can copy or move files from one location to another without opening windows in the Finder.
  • You can copy or move files that are hidden in the Finder. These files, which can contain settings for certain apps or parts of the Mac, contain a dot (.) before their names, and the Finder doesn’t show them.
  • You can copy or move multiple files using wildcards.
  • You can rename a file quickly.
  • If you’ve lost access to the Finder because your Mac is on the blink, you might be able to use the command line to troubleshoot the problem.


Information about How to Use

  • use “cd” command fallowed by path of executable file’s diractory
  • if you put executable file to “/ ” you can execute file right after opening terminal
  • To execute program use “./DirectoryCreator”

How to copy files and directories

Copying files with the cp command is simple. First, launch Terminal (in your /Applications/Utilities folder). Then, use the following syntax to create your command:

cp source destination

For example, to copy a file named MyFile.rtf from your Desktop folder to your Documents folder, you would type in the following command in Terminal and then press Return:

cp ~/Desktop/MyFile.rtf ~/Documents

You’ll now have a file named MyFile.rtf on your Desktop, and a copy of that file in your Documents folder.

You’ll remember from “Master the command line: Navigating files and folders” that the tilde (~) symbol is a shortcut for your Home folder, which contains your Documents folder. This command takes the file at the precise path you specify as the source argument, and moves it to the directory (folder), which is the destination. Note that if there’s no file there, or if you type the name incorrectly, Terminal will give you a “No such file or directory” error.

If you type a file path incorrectly, Terminal wi

If you type a file path incorrectly, Terminal will let you know with a “No such file or directory” error.


You can also copy directories, including all the files they contain. This uses a special “flag” or “option” with the cp command: the -R or recursive flag. When you use options with commands, this additional letter—always preceded by a hyphen (-)—tells the command to do something a bit differently. The recursive option tells the cp command to copy every item in the folder: every sub-folder, every file and folder in every sub-folder, and so one, all the way down, to the new location. So you can copy a directory from your Desktop to your Documents folder like this:

cp -R ~/Desktop/MyFolder /Documents

How to access the secret folder

* Now click back to the Finder, and hit Command+Shift+G to bring up the ‘Go to Folder’ dialog box * Type in the full path to the folder you just created, replacing ‘username’ and ‘hiddenfolder’ with your username and folder name, respectively: /users/username/.hiddenfolder/ 
* Your hidden folder will now be opened in the Finder, you can drag and drop whatever you want into the directory

How to use:

  • Open terminal.
  • Set current directory as where executable file is. (See below for more information)
  • Execute it from terminal. (See below for more information)
  • Provide relavent information when asked.
  • Tool first asks Series name than which season and finally how many episodes does that season has.
  • Your directories are created. (You will see a list of created directories full path)

Information about Permissons:

When you download executable file you won’t have permisson to execute it. You should change permissions to execute. To do so you can use “chmod 700 PATH” where PATH is path of file. (You can drag and drop file to terminal window instead of typing path)

The Basics of Bash

Now that we understand how scripts and shells work, it’s time to go over a few tips about scripting with bash. After that, we’ll dive into the basics like assigning variables and writing conditionals. 

Word Separation

One of the first major building blocks to wrap your head around is how bash uses word separators. While looking at examples of script, you’ll see metacharacters like ; and &. These are just two of the seven characters that bash uses to separate words while scripting.

We’ll include a list of all seven below. When you see these, don’t worry. They just keep everything organized. As you’ll see later in the conditionals section, the type of syntax used depends on what you’re trying to accomplish.

  • (
  • )
  • <
  • >
  • ;
  • |

Useful Organization Commands

Bash also gives you a number of commands you can use to organize files. We covered some of these in the Terminal command section, but here are a few more:

  • mkdir (make directory) is used to create a new directory or folder.
  • mv (move) is used to move one or more files or directories to another place.
  • rm (remove) is used to delete files.
  • rmdir (remove directory) is used to delete a directory.

Viewing Commands

If you want to do more than just move files around, you can use some of these viewing commands to see the information that the files contain. Here are two of them:

  • cat (concatenate) reads the content of one or more files and displays it. This is ideal for shorter files.
  • less is another viewing command that’s great for viewing longer files because it only displays one screen of information at a time and includes useful navigation features to search for specific words or go to the next or previous page.

What are Variables?

Variables are named placeholders that refer to a certain value. When you type in the variable name, the system treats it as if you’ve typed in the value it refers to. You can name variables using numbers, letters, filenames, or other types of data.

Variables make it easier to write scripts that use specific chunks of data — even if that data is always changing, such as usernames. Rather than write separate commands for multiple variations of usernames, you can just define a username variable and use it as a placeholder for all of the variations that users might use.

Assigning variables is pretty easy to do. You just have to specify a variable name and a value, like so:

Capitalization doesn’t matter here. The variable name and value can be just about whatever you want, such as:

That said, there are some restrictions about what words or characters you can use for variables (which we’ll cover next). But first, it’s important to note that bash does not use spaces before or after the equal sign while assigning variables.

That means you can’t assign a variable with spaces, like this:


You have to assign it without spaces, like this:


However, you can use spaces in variables names by using quotes, like this:


We should also mention that you can use a Mac script to tell Terminal to return the value of a variable to you. You can do this in two ways. In both examples, “x” is the variable value that you’re looking for:

You can also make a variable refer to the result of a command, such as:

Variable Restrictions

So, what are those variable restrictions we just mentioned? Bash has twenty “reserved words” that you can’t use for variables because they’re already assigned to other important functions within the shell. Whenever you’re assigning variables, you just have to avoid these words and you won’t run into any problems with your script.

Here they are:

  • ! and time
  • [[ and ]]
  • { and }
  • if, then, elif, else, and fi
  • case and esac
  • select and in
  • while, until, for, do, and done
  • function

Single vs. Double Quotes

Text encapsulated in single quotes means it contains strictly that text as read – it won’t give meaning to any special characters, such as variables or variable restrictions.

Double quotes preserves the literal value of some characters, but it can contain some variables or characters with special meaning in them, including:

The meaning of the character ! within double quotes is preserved only when history expansion is enabled, and \ must be followed by another special character (or a new line).

What are Conditionals?

The next big step in learning Mac scripting is figuring out how to use conditionals. Essentially, conditionals are if/then statements, which set conditions and then see if they’re being met (i.e. IF it’s 6am, THEN say “Good morning”).

In bash, the syntax of if/then statements looks like this:

Let’s break that down.

  1. Start with “if” and immediately follow it with its conditions.
  2. Use a semicolon to separate the “IF” condition and begin the “THEN” command. This command will only take place if the “IF” condition is met.
  3. Finally, close the if/then statement with “fi” – this is just “if” spelled backward.

Here’s an example:

Here, we’re checking to see if a number, 5, is greater than or equal to (that’s the “-ge”) another number, 4. If it is, the “then” command will be executed, prompting us with a message: “That number is greater than or equal to 4.” Imagine how changing out the 5 and using a variable instead could improve the functionality of this script.

Once you get a hold of these statements, you can learn how to use “else” to give your commands an alternative action in the event that the “if” conditions aren’t met. For more complicated commands, you can even use “elif” (else if) to add conditions to “else” without tediously rewriting more “else” conditions.

About This Article

Co-authored by: Yaffet Meshesha Computer Specialist This article was co-authored by Yaffet Meshesha. Yaffet Meshesha is a Computer Specialist and the Founder of Techy, a full-service computer pickup, repair, and delivery service. With over eight years of experience, Yaffet specializes in computer repairs and technical support. Techy has been featured on TechCrunch and Time. This article has been viewed 39,901 times. How helpful is this? Co-authors: 3 Updated: March 16, 2021 Views: 39,901 Categories: Mac

Thanks to all authors for creating a page that has been read 39,901 times.