Reputation: 122052
How do I bash a command or a shell script to move all the files from the subdirectories to one target directory in Linux?
Upvotes: 9
Views: 11220
Reputation: 36049
If you are using GNU mv, the -t
option (target directory) is pretty useful:
find sourcedir -type f -print0 | xargs -0 mv -t target
man mv
gives more details.
Upvotes: 14
Reputation: 15245
Try something like this:
find sourcedir -type f -exec mv {} targetdir \;
Upvotes: 8