将一个文件夹中的文件名大写的全部改为小写

有时候下载的数据集内的文件名会不分大小写,但是一般的语言机制都对大小写敏感,因此找了一个可以将一个文件夹中的文件名大写全部改为小写。matlab代码如下:

%将文件夹中的文件名中的大小全部改为小写

path = 'F:\CNNIQA-master+IQA数据集\media\ldq\Research\Data\tid2008\distorted_images/';  %要修改的文件夹路径
Files = dir(fullfile(path,'*.bmp'));
LengthFiles = length(Files);
for count_i = 1 : LengthFiles;
flag = 0;
origin_name = Files(count_i).name;
for count_j = 1 : length(Files(count_i).name)
if ( Files(count_i).name(count_j) <= 'Z' ) && ( Files(count_i).name(count_j) >= 'A' )
Files(count_i).name(count_j) = Files(count_i).name(count_j) + ('a' - 'A');
flag = 1;
end
end
if flag == 1
realName = [path, origin_name];
tmpName = [path, 'azbxsjdskjfslkdjflksdjfsldkjf'];
changeName = [path, Files(count_i).name];
movefile(realName, tmpName);
movefile(tmpName, changeName);
end
end

  源链接如下:https://www.cnblogs.com/fdd566/archive/2017/03/06/6512508.html

转载于:https://www.cnblogs.com/libai123456/p/10175995.html

你可能感兴趣的:(matlab,python,ruby)