简体   繁体   English

在Windows上使用Matlab创建一个.txt文件,该文件列出目录中的所有文件

[英]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获取目录列表,您应该仅使用内置dirls获取文件列表,然后使用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.

相关问题 从Windows中目录和子文件夹的* .txt文件中删除所有空白行 - Remove all blank lines from *.txt files in the directory and subfolders in Windows 批处理文件:列出目录中的所有文件,打印为.txt并将输出文件放置在所有子目录中 - Batch Files: List all files in a directory, print as .txt and place output file in all sub directories 如何将目录中的所有* .txt文件写入一个文件中,并在输出文件的每一行中包含源文件名? - How to write all *.txt files in a directory into one file with source file name in each line in output file? 将目录中的所有 JSON 文件合并为一个文件 - Windows - Combine all JSON files in a directory into one file - Windows 如何在Windows中将权限从参考文件传播到目录中的所有文件? - How to propagate permissions from reference file to all files in a directory in Windows? 如何使用C ++列出Windows目录中的所有CSV文件? - How to list all CSV files in a Windows Directory using C++? 批处理文件[计划任务]将所有.txt文件复制到rot目录下 - Batch File [scheduled task] copying all .txt files under a rot directory 如何创建批处理文件以运行同一目录中的所有python文件 - How to create a batch file to run all python files in the same directory 创建一个批处理文件,该文件读取当前目录中包含的所有文本文件 - Create a batch file that reads all the text files contained in current directory 批处理文件列出在Windows Server 2008上具有特定文件名和特定内容的所有txt文件 - Batch file to list all txt files with a certain filename and certain content on windows server 2008
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM