Script to escape from subdirs required


I’m hoping that someone here can point me in the right direction to solve a problem I have.

I have a directory, let’s call it “directory”.

Within this directory I have 100 sub-directories, called “subdirA”, “subdirB”, “subdirC”,…

Within each of these subdirectories I have ONE file.



What I’d like to do is extract the files from the subdirectories and store them in the main directory, eg.


Does anyone know of a way to do this OTHER THAN MANUALLY? Is there a script that will do this?


Hi Bob,

Thanks for the reply, it is much appreciated.

My problem was that it was taking forever to upload the existing directory/subdirectory/file structure via FTP. It was only once I’d switched my brain on that I realised there was an easier way to do it. I simply zipped the local structure, FTPd the zip file to DreamHost, then unzipped on the server via SSH. It had taken me 3 days to get half way through the list using FTP - it took 5 minutes using the zipped file and SSH.

The bottom line, for those who don’t know it yet, is to use SSH and one zipped file instead of FTP when you want to upload a large number of directories/subdirectories.

Thanks to DH support for all help in this task.