Can `mv` move multiple files at once?

QuestionsQuestions8 SkillsProDec, 18 2025
0203

Yes, absolutely! The mv command is very flexible and can move multiple files to a directory at once.

To do this, you list all the files you want to move, and specify the destination directory as the very last argument.

Syntax:

mv file1.txt file2.txt file3.txt destination_directory/

Examples:

  1. Explicitly naming files:
    If you have file1.txt and file2.txt and want to move both to testdir:

    mv file1.txt file2.txt testdir/
  2. Using Wildcards (Patterns):
    If you want to move all .txt files in your current folder to testdir, you can use the asterisk * wildcard:

    mv *.txt testdir/
  3. Moving everything in a folder:
    To move all files and subdirectories from the current location to testdir:

    mv * testdir/

Important Note: When moving multiple items, the final argument must be an existing directory. If it isn't, the command will return an error.

Give it a try in your terminal! It's a great way to save time when organizing your project files.

0 Comments

no data
Be the first to share your comment!