MacOS – Bulk merge items sub-folders into new folder

findermacosmergeterminal

I have a main folder with about 80 folders in, each with about 10 items in. I want to be able to use a Terminal command or something to just move every item from each sub-folder into a new one (i.e the newly created folder would have around 800 items in, not separated by individual folders). Doing this by hand would be very tedious. Is there a way to do it easily and quickly? I have looked at ditto, but couldn't figure out how to use it for my use case. Any help would be much appreciated, thank you!

Best Answer

Assuming the structure is like

main-folder
    subfolder-1
        item-1
        item-2
    subfolder-2
        item-3
        item-4

and all the items are uniquely named, you can use

cd main-folder
mkdir ../target-folder
mv */* ../target-folder/

to move everything into a target folder on the same directory level as the main folder. If you just want to move everything into the main folder, just use

cd main-folder
mv */* .