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

1 Ansicht (letzte 30 Tage)
Larry Lai
Larry Lai am 12 Jul. 2018
Kommentiert: Larry Lai am 13 Jul. 2018
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 Kommentare
Paolo
Paolo am 12 Jul. 2018
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 am 12 Jul. 2018
Hi Paolo
Yes, please find the attached text file.
Thanks

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Paolo
Paolo am 12 Jul. 2018
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 Kommentare
Paolo
Paolo am 13 Jul. 2018
Are the files located in the current directory? Is their extension .txt?
Larry Lai
Larry Lai am 13 Jul. 2018
The files located in the different directory. Please find the files structure as following: http://bids.neuroimaging.io/
Thanks

Melden Sie sich an, um zu kommentieren.

Kategorien

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

Tags

Produkte


Version

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by