How can I move all files in subdirectories recursively to a single directory?

Bunny Rabbit

I am trying to collect all the files under the current directory and all the subdirectories to one directory. I am trying something like the following

find -type f -exec mv {} collection/{} \; 

the above command won't work because the second {} gives the full path, how can I collect all the files?

Lekensteyn

Remove the {} from mv, mv will take it as target directory ignoring any parent directories:

find -type f -exec mv {} collection/ \;

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How can I move all files in subdirectories recursively to a single directory?

From Dev

How can I recursively copy all pdf files in a directory (and it's subdirectories) into a single output directory?

From Dev

How can I recursively list Md5sum of all the files in a directory and its subdirectories?

From Dev

How can I exclude all subdirectories but include files of a directory in rsync?

From Dev

How can I exclude all subdirectories but include files of a directory in rsync?

From Dev

How to move all files with a certain file extension from subdirectories to a single directory

From Dev

How can I move files into subdirectories by count?

From Dev

How do I recursively remove subdirectories and files, but not the first parent directory?

From Dev

How can I move files by type recursively from a directory and its sub-directories to another directory?

From Dev

How can I move files by type recursively from a directory and its sub-directories to another directory?

From Dev

Move all files from subdirectories to parent directory

From Dev

Move files from subdirectories into single directory and prefix original directory name

From Dev

How can I move files using bash/for loop inside subdirectories?

From Dev

How to move and overwrite subdirectories (and files) to parent directory?

From Dev

How to move all subdirectories to current directory?

From Dev

How can I recursively delete all files of a specific extension in the current directory?

From Dev

How can I recursively delete all files of a specific extension in the current directory?

From Dev

How can I automatically convert all source code files in a folder (recursively) to a single PDF with syntax highlighting?

From Dev

how can I extract multiple gzip files in directory and subdirectories?

From Dev

how can I extract multiple gzip files in directory and subdirectories?

From Dev

How can I list subdirectories recursively for HDFS?

From Dev

How can I list subdirectories recursively?

From Dev

How can I set all subdirectories of a directory into $PATH?

From Dev

How do I copy all files recursively to a flat directory in Ruby?

From Dev

How do I gunzip all files recursively in a target directory?

From Dev

Can I search directory and subdirectories for header files?

From Dev

Can I search directory and subdirectories for header files?

From Dev

How can I list all files, but only in directories that have no subdirectories?

From Dev

How can I recursively find a directory by name and delete its contents (including all sub-directories and files) while keeping the directory itself?

Related Related

  1. 1

    How can I move all files in subdirectories recursively to a single directory?

  2. 2

    How can I recursively copy all pdf files in a directory (and it's subdirectories) into a single output directory?

  3. 3

    How can I recursively list Md5sum of all the files in a directory and its subdirectories?

  4. 4

    How can I exclude all subdirectories but include files of a directory in rsync?

  5. 5

    How can I exclude all subdirectories but include files of a directory in rsync?

  6. 6

    How to move all files with a certain file extension from subdirectories to a single directory

  7. 7

    How can I move files into subdirectories by count?

  8. 8

    How do I recursively remove subdirectories and files, but not the first parent directory?

  9. 9

    How can I move files by type recursively from a directory and its sub-directories to another directory?

  10. 10

    How can I move files by type recursively from a directory and its sub-directories to another directory?

  11. 11

    Move all files from subdirectories to parent directory

  12. 12

    Move files from subdirectories into single directory and prefix original directory name

  13. 13

    How can I move files using bash/for loop inside subdirectories?

  14. 14

    How to move and overwrite subdirectories (and files) to parent directory?

  15. 15

    How to move all subdirectories to current directory?

  16. 16

    How can I recursively delete all files of a specific extension in the current directory?

  17. 17

    How can I recursively delete all files of a specific extension in the current directory?

  18. 18

    How can I automatically convert all source code files in a folder (recursively) to a single PDF with syntax highlighting?

  19. 19

    how can I extract multiple gzip files in directory and subdirectories?

  20. 20

    how can I extract multiple gzip files in directory and subdirectories?

  21. 21

    How can I list subdirectories recursively for HDFS?

  22. 22

    How can I list subdirectories recursively?

  23. 23

    How can I set all subdirectories of a directory into $PATH?

  24. 24

    How do I copy all files recursively to a flat directory in Ruby?

  25. 25

    How do I gunzip all files recursively in a target directory?

  26. 26

    Can I search directory and subdirectories for header files?

  27. 27

    Can I search directory and subdirectories for header files?

  28. 28

    How can I list all files, but only in directories that have no subdirectories?

  29. 29

    How can I recursively find a directory by name and delete its contents (including all sub-directories and files) while keeping the directory itself?

HotTag

Archive