Combining Folders

11 Ansichten (letzte 30 Tage)
Gaby R
Gaby R am 8 Nov. 2011
I have a bunch of folders that have common data. I'm hoping that I can combine all of them with a script in Matlab then create a master .txt with the content. Like the unzipping command, is it possible to dump all the content of multiple folders into one location without having to do it manually? Maybe there's a perl/C script I can use instead?
i.e., Folders= content_20110506, content_20110510, content_20110620. each folder have: doc_20110506.txt, doc_20110510.txt, doc_20110620.txt.
I want to end up with one folder that has all the txt files after taking them out of the "content" folders.
Thanks.

Antworten (2)

Jan
Jan am 8 Nov. 2011
If you work under Windows, I'd use the search function of the Windows Explorer to find all files insider the base folder, which match doc_*.txt. Then you can copy these files and paste them into a new folder. Under MacOS and Linux you find similar easy solutions.
Doinf this programmatically in Matlab is not hard also. There are a lot of functions in the FEX to fuind files recursively in subfolders. Move them using MOVEFILE.

Daniel Shub
Daniel Shub am 8 Nov. 2011
I wouldn't use MATLAB for this. From the CLI in Linux you can do:
find ./ -type f -exec cp {} FullPathToNewDirectory \;
Assuming you are in the topmost directory for the content directories ...
I am not sure about how find works on Windows.
You can then use the same strategy for combine them:
find FullPathToNewDirectory -type f -exec echo {} >> ./master.txt \;

Kategorien

Mehr zu File Operations finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by