Hi Jack,
In order to move or rename files programmatically, I would recommend looking at the "movefile" function. I'm not sure if I understand your entire question, but assuming in your main file tree, you have folders titled 2, 4, 6, 8, and 10, you can programmatically move into these folders by "cd"ing into them, getting a list of the folder names inside of them (assuming the only folders are +3um, +5um, etc), moving those files up one level, and then renaming them after moving. If you wanted to add "0s" before the number, you could process the strings (ex: taking the first character, concatenating zeros in the middle, and then adding the last characters after that), but below is a small example of how to do everything but that:
mainFileTree = {'2','4','6','8','10'}; % Make sure these are the full path to the folders
for i = 1:5
% For each of the main folders (2, 4, 6, 8, 10)
cd(mainFileTree{i}) % Change to appropriate directory
dirData = dir;
folderNames = {dirData.name};
for j = 1:4
currentFolderName = folderNames{j}; % Figure out which folder it is in
cd(folderNames{j})
movefile('B0001.m','../') % Move up one level
% Rename file
movefile('B0001.m', [currentFolderName 'x.m'])
end
Is there a particular reason why your files need to have those specific names in that particular structure to be processed? If you are doing the processing in MATLAB, you should be able to navigate through the appropriate directories no matter what the name is.
Hope this helps!