Hi Sneha,
As I understand the question, there are subfolders within the folder which have a single (or multiple) .MF4 files in them. The names of those files (not the folders) have to be changed to the modified timestamp.
The following code changes the names of all the files in the folder structure that you have sent to the modified unix timestamp of that particular file.
root = 'C:\path\to\root\folder'; % specify the path to the root folder
directories = dir(root);
% As in the image sent by you, there are several directories and each of
% them have a file whose name has to be changed. So, looping through those
% directories here.
for i = 1:length(directories)
dirName = directories(i).name;
if strcmp(dirName, '.') || strcmp(dirName, '..') % The '.' and '..' directories are to be omitted because they represent the current and previous directories
continue;
end
fullPath = fullfile(root, dirName);
files = dir(fullPath);
for j = 1:length(files)
file = files(j).name;
if strcmp(file, '.') || strcmp(file, '..') % These files are to be skipped even inside the directory as they are present in every level
continue;
end
filePath = fullfile(fullPath, file);
fileInfo = dir(filePath);
unixTime = (fileInfo.datenum - datenum(1970,1,1)) * 24 * 60 * 60; % convert to Unix time
newFileName = [num2str(unixTime), '.MF4']; % new file name has the unix timestamp of modification as its name
newFilePath = fullfile(fullPath, newFileName); % new file path that includes the modified file name
movefile(filePath, newFilePath); % changing the file path to include the new file name
end
end
As mentioned, I've used the Unix time stamp that includes information on both time and date. The format of representation can be changed as required.