用matlab自带的导入txt中数据功能生成了脚本,但是怎么才能对我的所有想操作的txt都批量操作呢?

这里有三百多个txt文件,每个文件都要进行下面代码中的操作

img

这里是matlab导入数据自动生成的代码

%% 从文本文件中导入数据
% 用于从以下文本文件中导入数据的脚本:
%
%    filename: D:\OneDrive\桌面\建模Matlab代码\附件1:UWB数据集\正常数据\1.正常.txt
%
% 由 MATLAB 于 2021-11-20 14:26:22 自动生成

%% Set up the Import Options and import the data
opts = delimitedTextImportOptions("NumVariables", 9);

% 指定范围和分隔符
opts.DataLines = [1, Inf];
opts.Delimiter = ":";

% 指定列名称和类型
opts.VariableNames = ["T", "VarName2", "DecaRangeRTLS", "LogFile", "zm", "Conf", "Tag0", "VarName8", "Chan2"];
opts.VariableTypes = ["string", "string", "string", "string", "string", "string", "string", "string", "string"];

% 指定文件级属性
opts.ExtraColumnsRule = "ignore";
opts.EmptyLineRule = "read";

% 指定变量属性
opts = setvaropts(opts, ["T", "VarName2", "DecaRangeRTLS", "LogFile", "zm", "Conf", "Tag0", "VarName8", "Chan2"], "WhitespaceRule", "preserve");
opts = setvaropts(opts, ["T", "VarName2", "DecaRangeRTLS", "LogFile", "zm", "Conf", "Tag0", "VarName8", "Chan2"], "EmptyFieldRule", "auto");

% 导入数据
Untitled = readmatrix("D:\OneDrive\桌面\建模Matlab代码\附件1:UWB数据集\正常数据\1.正常.txt", opts);


%% 清除临时变量
clear opts
Untitled(1,:)=[];
X=[];m=1;
for i=1:size(Untitled,1)
    if mod(i,4)==0
        X(m,4)=double(Untitled(i,6));
        m=m+1;
    else
        X(m,mod(i,4))=double(Untitled(i,6));
    end
end
X=unique(X,'row')


请问我需要如何修改才能批量的对我上面的文件夹中的txt文件经行操作呢?