Operations 4 min read

How to Move Multiple File Types at Once in Linux Using mv

This guide demonstrates two straightforward Linux command‑line techniques—brace expansion and wildcard patterns—to move several file extensions (e.g., .doc, .pdf, .txt) from one directory to another in a single step, complete with examples and verification commands.

Liangxu Linux
Liangxu Linux
Liangxu Linux
How to Move Multiple File Types at Once in Linux Using mv

Moving a single file type is easy, but moving several types simultaneously can be cumbersome. This guide shows two simple methods to move multiple file extensions in Linux using the mv command.

Method 1: Using brace expansion

Assume directory dir1 contains files of various types such as .pdf, .doc, .mp3, .mp4, .txt, etc. List its contents:

$ ls dir1
file.txt image.jpg mydoc.doc personal.pdf song.mp3 video.mp4

To move only .doc, .pdf, and .txt files to another directory dir2, run:

$ mv dir1/*.{doc,pdf,txt} dir2/

Verify the result:

$ ls dir1/
song.mp3 video.mp4
$ ls dir2/
file.txt mydoc.doc personal.pdf

The brace list can include any extensions you need.

Method 2: Changing to the source directory first

Navigate to the source directory:

$ cd ~/dir1

Then move the selected extensions directly:

$ mv *.doc *.txt *.pdf /home/alvin/dir2/

You can also move a single extension, e.g., all .doc files:

$ mv dir1/*.doc dir2/

For more options, consult the manual page:

$ man mv

Summary

Using a one‑line mv command with brace expansion or wildcard patterns lets you relocate multiple file types efficiently, saving time compared to moving each type individually.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

ShellBashmv command
Liangxu Linux
Written by

Liangxu Linux

Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.