Sorting file (from a text file) and copying file to the new folder

조회 수: 1 (최근 30일)
Larry Lai
Larry Lai 2018년 7월 12일
댓글: Larry Lai 2018년 7월 13일
Dear MATLAB experts
I want to sort the content of file based on the text file (e.g. *.txt) and then copy all the list files into another directory.
Source: C:\ sub001 (a list of subjects on the text file) ○ A ■ Sub-directory ○ B ■ Sub-directory
Text file: sub001 , sub002 and etc.
Destination: D:\Sorter
--
Thanks for considering my questions.
Best wishes
Larry Lai
  댓글 수: 2
Paolo
Paolo 2018년 7월 12일
So you want to open text files, read their contents and move said files to a different destination according to the contents?
What do the text files look like?
Larry Lai
Larry Lai 2018년 7월 12일
Hi Paolo
Yes, please find the attached text file.
Thanks

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

답변 (1개)

Paolo
Paolo 2018년 7월 12일
If I am understanding the question correctly the following should help you:
fid = fopen('SubjectsID.txt')
while ~feof(fid)
tline = fgetl(fid);
name = strcat(tline,'.txt');
movefile(name,'D:\Sorter')
end
  댓글 수: 3
Paolo
Paolo 2018년 7월 13일
Are the files located in the current directory? Is their extension .txt?
Larry Lai
Larry Lai 2018년 7월 13일
The files located in the different directory. Please find the files structure as following: http://bids.neuroimaging.io/
Thanks

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

카테고리

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

태그

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by