Extract files from folders with same ID

조회 수: 1 (최근 30일)
Muhammad Zafar Iqbal
Muhammad Zafar Iqbal 2018년 5월 8일
답변: Muhammad Zafar Iqbal 2018년 5월 8일
Hi everybody I am a new user of MATLAB. I have a text file with first row containing ID ( 'EventID = 72450561') of the event and then there are about 150(Stations) rows (Two columns, Name and Distance separated by tab like "BAV 14") then there is another event ID and the same pattern of Stations. In Directories with same IDs having stations files (*.SAC) like (NC.BAV..EHZ.D.2010.007.071549.SAC). There are more than 300 files in each directory. I need to extract only files comparing the name like in text in a separate folder. How can I do it to save my time? Regards ZAFAR
  댓글 수: 3
KSSV
KSSV 2018년 5월 8일
Zafar commented: I need to Pick Stations files(NC.BAV..EHZ.D.2010.007.071549.SAC) compared with txt fileand make output as a separate folder with ID like 72450561
KSSV
KSSV 2018년 5월 8일
So do those text files names have anything in common?

댓글을 달려면 로그인하십시오.

채택된 답변

KSSV
KSSV 2018년 5월 8일
If your names of text file have any word/ number common you may use dir command to extract those filenames. Example say you want text files having name 071549 common.
files = dir('*071549*') ;
will give you names of files having that name in common. Then you can move those files using movefile. So read aboout dir and movefile.

추가 답변 (3개)

Muhammad Zafar Iqbal
Muhammad Zafar Iqbal 2018년 5월 8일
or just delete files from the folder which is not present in the text file

Muhammad Zafar Iqbal
Muhammad Zafar Iqbal 2018년 5월 8일
ID is common in txt files or csv files. Column 1 is ID same with folder Name, 2nd column is Station Name

Muhammad Zafar Iqbal
Muhammad Zafar Iqbal 2018년 5월 8일
I am here waiting for solution

카테고리

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