ytrewq
ytrewq

Reputation: 3930

Collect files from all subdirectories

I have a directory with about 5,000 subdirectories in it.

Each subdirectory contains one file each.

I'd like to collect those files and put them in the same folder somewhere.

Is there a way to do that by Mac OSX terminal command? Or should I write a, say, python script to do that?

Upvotes: 0

Views: 157

Answers (1)

Wang
Wang

Reputation: 3357

Something like,

find . -type f -exec echo mv {} /path/to/dst/dir/ \;

You'll have to tweak this according to your circumstances, of course. See man find for details. Remove the echo when you're ready to run for real (preferably after taking a backup).

Upvotes: 1

Related Questions