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.
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.mp4To 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.pdfThe brace list can include any extensions you need.
Method 2: Changing to the source directory first
Navigate to the source directory:
$ cd ~/dir1Then 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 mvSummary
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.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
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.)
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
