I am trying to create a MATLAB loop where I can copy all the files listed in a txt file sent to me by a colleague from one directory on my computer to another.
The code I am using is:
FileList=textread('C:\Users\Desktop\list.txt','%s')
%copy files in list from one folder to another
cd ('C:\Users\source_directory')
for n=1:numel(FileList)
source=FileList(n)
destination='C:\Users\destination_directory'
copyfile(source,destination)
end
I keep getting this error: "Error using copyfile Argument must contain a string."
My FileList is a cell character array, but I also cannot convert to a string. When I try I get this:
string(FileList) Warning: string is obsolete and will be discontinued. Use char instead. Error using string Conversion to char from cell is not possible.
Please help! Thank you.