Skip to content

Help us create more tutorials! Make a donation using the Donate button or become a member using the button below to hide this banner and track your progress.

Move file or folder – Terminal


To move a file using your terminal, use the mv command:

mv my-file my-folder

To move a folder using your terminal, you also use the mv command:

mv first-folder second-folder


If there is already a file named my-file in the destination folder, the above command will overwrite it with the contents of the new my-file, and you will lose what was inside the original my-file file. Use the mv command with caution.



If you had a file named index.html that you wanted to move to a folder called my-folder, you would enter the following command in your terminal:

mv index.html my-folder

You can use more complex file paths if necessary:

mv old-folder/index.html ../new-folder/subfolder

Move multiple files or folders

To move multiple files into a folder, pass in the file names as arguments in between the mv command and the destination, like this:

mv index.html about.html new-folder

The above command will move index.html and about.html to new-folder.

You can also use multiple folder names as arguments to move multiple folders, like this:

mv folder-1 folder-2 new-folder

The above command will move folder-1 and folder-2 to new-folder.


You can use the -i flag to add a prompt asking if you want to overwrite an existing file. For example, let’s say you want to move index.html into folder-1, which already has a index.html file inside it. With the -i flag, you’ll see the following prompt:

overwrite folder-1/index.html? (y/n [n])

You can type the letter y or n and press Enter to either overwrite the file or not.

You can also use the -v flag to get verbose output. For example, if you use the flag and overwrite the file in the example above, you would see the following output:

index.html -> folder-1/index.html

You can combine the 2 flags, like this:

mv -iv index.html folder-1


Try the following command in your project folder:

mv main.css css


Command Line Primer on the Apple Developer Archive (see the section called Frequently Used Commands)

Back to: Terminal Course > Terminal Advanced Commands