Something like this might help:
function [oldFiles,newFiles] = splitFile(folder)
dirList = dir(folder);
isDir = [dirList(:).isdir];
oldFiles = {dirList(~isDir).name};
newFiles = replace(oldFiles, 'splitted_', '');
end
then use movefile to rename the files on disk.
I'm guessing you might also like to read the files into a workspace variable, where the variable name is constructed based on the source file name. One useful concept here is the associative naming for structs.
mystruct.name = readtable('myfile.txt');
works, and so also does
mystruct.('name') = readtable('myfile.txt');
This second form is quite useful here, because you can process the filename (using functions like replace() or regexp()) and use the filename to construct a fieldname that is appropriate.
Best Answer