extracting files from multiple directories
Show older comments
Hello everybody! I have a simple problem to solve: I have 100 folders and each folder contains around 2000 files, called v1,v2,v3...and the names are the same for every folder. How can I extract specific files (e.g v2-v10) in every folder and organize them such that all the v1 are in one new folder and the v2 in a second folder? Thank you
8 Comments
Ingrid
on 8 May 2015
why would you like to do this with matlab?
the cyclist
on 8 May 2015
I assume the folder names and file names obey some pattern. Can you give some representative examples?
Camilla Santicoli
on 9 May 2015
Image Analyst
on 9 May 2015
That's what my attached program in my answer below does . Just change the starting folder and change the file pattern to simv*.* and put your reading and analysis code at the middle of the loop.
Camilla Santicoli
on 9 May 2015
Image Analyst
on 9 May 2015
Let's say that all 100 of your sim* folders lived under a parent folder called "All_My_Sim_Folders" - then that is what your starting folder would be.
Camilla Santicoli
on 9 May 2015
Image Analyst
on 9 May 2015
If that worked, maybe you could vote for my answer or mark it "Accepted".
Accepted Answer
More Answers (1)
Image Analyst
on 9 May 2015
2 votes
See my attached demo where I recurse into all subfolders of a folder and list the files. You could then do anything you want with each file. It will be easy for you to adapt this to your specific folder names.
Categories
Find more on File Operations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!