Files
imdd_silas/Functions/removeDotsFromFileNames.m
sioe e47a4dbbbe Many changes for 400G DSP
Minimal Example
...
2024-12-17 16:17:58 +01:00

48 lines
1.3 KiB
Matlab
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
folderPath = "/Volumes/NT-Labor/2024/sioe/High Speed Messungen Oktober/";
% Get list of all files in the folder and subfolders
fileList = dir(fullfile(folderPath, '**', '*'));
% Loop through each file
for i = 1:length(fileList)
% Get the file name and path
oldFileName = fileList(i).name;
oldFilePath = fullfile(fileList(i).folder, oldFileName);
% Skip if its a directory or hidden file
if fileList(i).isdir || startsWith(oldFileName, '.')
continue;
end
ismat = strfind(oldFileName, '.mat');
if ismat
continue;
else
% Find position of last dot (for file extension)
dotIndex = strfind(oldFileName, '.');
% Only proceed if there is more than one dot in the file name
if ~isempty(dotIndex)
% Replace all dots in the "base name" with underscores
sanitizedBaseName = strrep(oldFileName, '.', '_');
% Create the new file name with the corrected extension
newFileName = [sanitizedBaseName, '.mat'];
% Full path of the new file
newFilePath = fullfile(fileList(i).folder, newFileName);
% Rename the file
movefile(oldFilePath, newFilePath);
fprintf('Renamed: %s -> %s\n', oldFilePath, newFilePath);
end
end
end