How to move files from multiple folders?

QuestionsQuestions4 SkillsProBasic Files OperationsSep, 29 2025
0137

To move files from multiple folders in Bash, you can specify the full paths of the files you want to move, or use wildcards to select files from different directories. Here are a couple of methods:

Method 1: Specify Full Paths

If you know the exact paths of the files, you can list them all in the mv command:

mv /path/to/dir1/file1.txt /path/to/dir2/file2.txt /path/to/dir3/file3.txt /path/to/destination/

Method 2: Using Wildcards

If you want to move files that match a certain pattern from multiple directories, you can use wildcards. For example, to move all .txt files from dir1 and dir2 to a backup directory:

mv /path/to/dir1/*.txt /path/to/dir2/*.txt /path/to/backup/

Notes

  • Ensure that the destination directory exists before running the command.
  • If you want to move files based on specific criteria (like modification time), you might need to use additional commands like find.

If you need more examples or have further questions, feel free to ask!

0 Comments

no data
Be the first to share your comment!