You can use uigetfile to easily select mutliple files and make the filename acquisition process a little more simple.
msg = "Select all *.xlsx data file(s) for processing"
[path,files] = uigetfile(fullfile(pwd,'*.xlsx'),msg,"MultiSelect","on");
Added your normal code to a loop. This task can be simplified, but using this format to make interpretation easier. Also, it is recommended to use readmatrix instead of xlsread, as it is much quicker.
if ~isnumeric(path)
file = cellstr(file);
for i=1:length(filename)
filename = fullfile(path,file{i});
[d1,tex] = xlsread(filename);
A1 = d1(:,1);
B1 = d1(:,2);
C1 = d1(:,3)
results = mean(C1)
A = [{filename(1:4)} num2str(results)]
writecell(A,[char(filename(1:4)), '.txt'],'Delimiter','tab')
end
end