MATLAB: Add same to different paths

addpathcd folderrmpathuse same folder as input for all other folders

I have a folder, which has some excel sheets. These excel sheets are taken as input for my code.
I am using cd and addpath and rmpath functiions to automatically run this script in different folders.
I need to run this code in 5 different folders. Input files in folders are same. There are around 800 input files. I dont want to copy paste these files in all 5 folders.
Is there any way by which I could call the files from one folder as input in all 5 different folders while running code.
I tried using shortcuts , but it did not work.

Best Answer

You can address a file using the full path:
Folder = 'C:\DataPath'; % Set accordingly
List = dir(fullfile(Folder, '*.xlsx');
for iList = 1:length(List)
File = fullfile(Folder, List(iList).name);
... Operations with the file here
end
Now accessing the files is independent from th current folder.