Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have a directory that contains around 100 subdirectories. I want to take all the files from this directories and add them to the first directories then delete them all. Is this possible?

share|improve this question
add comment

3 Answers 3

up vote 3 down vote accepted

You can paste a command like this at terminal:

find /source/dir/* -exec mv {} /destination/dir/ \;
share|improve this answer
add comment

Call me old-fashioned, but I'm usually using Midnight Commander for this :) You can install it using

sudo apt-get install mc

then start it by typing

mc

then hit Esc, Ctrl-?, enter your search criteria, click [ Panelize ] button - voila, you can do anything you want with your files - copy, move, delete... the nice thing about using mc is that you can review the list of files and manually select only some of them... i.e. sort the result by size and delete only the 10 largest files, for example, or select files by size so they fit on a CD as close as possible, etc.

share|improve this answer
add comment

Execute the following in the root directory: find -exec mv {}/* . \;

This puts all files from all subdirectories in the directory in which you execute it.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.