Combining Folders

조회 수: 11 (최근 30일)
Gaby R
Gaby R 2011년 11월 8일
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.

답변 (2개)

Jan
Jan 2011년 11월 8일
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 2011년 11월 8일
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 \;

카테고리

Help CenterFile Exchange에서 File Operations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by