How to mv multiple files in linux

Content on WhatAnswers is provided "as is" for informational purposes. While we strive for accuracy, we make no guarantees. Content is AI-assisted and should not be used as professional advice.

Last updated: April 4, 2026

Quick Answer: To move multiple files in Linux, you can use the `mv` command followed by a list of the files you want to move, and then the destination directory. For example, `mv file1.txt file2.jpg /path/to/destination/` will move `file1.txt` and `file2.jpg` into the specified directory. You can also use wildcards like `*.txt` to move all files ending with `.txt`.

Key Facts

Overview

The Linux operating system provides a powerful and versatile command-line interface (CLI) that allows users to perform a wide range of tasks, from simple file operations to complex system administration. One of the most fundamental commands is `mv`, which stands for 'move'. While often used to rename files, its primary function is to move files and directories from one location to another within the filesystem. This capability is crucial for organizing your data, managing projects, and maintaining a clean and efficient file system. Moving multiple files at once is a common requirement, and Linux offers several straightforward ways to achieve this using the `mv` command, often in conjunction with shell features like wildcards.

Understanding the `mv` Command

The basic syntax for the `mv` command is:

mv [options] source destination

When moving a single file, the source is the file you want to move, and the destination is the target directory or the new name/path for the file.

When moving multiple files, the syntax extends to:

mv [options] source1 source2 source3 ... destination

In this case, source1, source2, source3, etc., are the files or directories you wish to move, and the destination must be an existing directory. All the specified sources will be moved into that directory.

Moving Specific Multiple Files

The most direct way to move multiple, specifically named files is to list them all in the command. For instance, if you have `report.txt`, `notes.md`, and `summary.pdf` in your current directory and you want to move them to a directory named `documents` (which already exists), you would use:

mv report.txt notes.md summary.pdf ~/documents/

Here, `~` represents your home directory, so `~/documents/` points to a `documents` folder within your home directory. If the `documents` directory does not exist, the command would likely fail or, depending on the exact `mv` implementation and context, might attempt to rename one of the source files to `documents` if only one source was provided, which is not the desired behavior for moving multiple files.

Leveraging Wildcards for Bulk Moves

Listing every file individually can be tedious, especially when dealing with many files that share a common pattern. This is where shell wildcards (also known as globbing patterns) become incredibly useful.

The Asterisk (`*`) Wildcard

The asterisk (`*`) is the most common wildcard. It matches any sequence of zero or more characters. For example:

Other Useful Wildcards

While `*` is the most frequent, other wildcards can refine your selection:

Important Considerations and Options

Destination Must Be a Directory

When using `mv` to move multiple items, the final argument must be an existing directory. If you provide a name that doesn't exist as a directory, `mv` might behave unexpectedly, potentially trying to rename the last source item to that name if only one source was given, or throwing an error if multiple sources are provided and the destination isn't a directory.

Overwriting Files

If a file with the same name already exists in the destination directory, `mv` will typically overwrite it without asking. This can lead to data loss if you are not careful. You can use the following options to manage this behavior:

Example using the interactive flag:

mv -i *.log /var/log/archive/

Verbose Output (`-v`)

To see exactly which files are being moved and where, you can use the `-v` (verbose) option:

mv -v *.jpg ~/backup/images/

This will print a line for each file indicating the source and destination, e.g., `'photo1.jpg' -> '/home/user/backup/images/photo1.jpg'`.

Moving Directories

The `mv` command works identically for moving directories. If you want to move a directory named `project_files` into another directory called `archives`, you would simply use:

mv project_files archives/

If you list multiple directories, they will all be moved into the specified destination directory.

Common Scenarios and Examples

Conclusion

The `mv` command in Linux is a fundamental tool for file management. By understanding its basic syntax and mastering the use of wildcards, you can efficiently move multiple files and directories, keeping your filesystem organized and your workflow smooth. Always be mindful of potential overwrites and consider using options like `-i` or `-n` for safety, especially when working with critical data.

Sources

  1. mv - move (rename) filesCC0-1.0
  2. GNU Coreutils: mv invocationGPL-3.0-or-later
  3. ExplainShell: mv command explanationfair-use

Missing an answer?

Suggest a question and we'll generate an answer for it.