[英]create a .txt file that lists all files in directory, using Matlab on Windows
I wrote this on my Matlab code for my MacOs: 我在MacO的Matlab代码上编写了此代码:
folder_list = 'folder_list.txt';
cd(folder_paraboles)
if exist(folder_list) == 0
commande = ['ls >',folder_list];
unix(commande)
end
Does anyone can give me the corresponding line code on Matlab Windows? 有谁可以在Matlab Windows上给我相应的代码? Thanks a lot 非常感谢
Rather than using unix
to get the directory listing, you should just use the built-in dir
or ls
to get a list of files and then write them out to a file using MATLAB's built-in ability to write to files. 而不是使用unix
获取目录列表,您应该仅使用内置dir
或ls
获取文件列表,然后使用MATLAB的内置写入文件功能将它们写出到文件中。
files = dir(pwd);
fid = fopen('output.txt', 'wt');
fprintf(fid ,'%s\n', files.name);
fclose(fid);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.