Copy the files with the same names from many folders into new one folder
Ältere Kommentare anzeigen
Dear all, could anyone help with this issue? We want to copy files with same names from many folders into new one folder. Example: 001/aaa.tiff, 002/aaa.tiff, ..., 555/aaa.tiff. - result new/001.tiff,002.tiff,003.tiff
If I do the dir of the folder there appears this list of folders: ., .., 001, 002, and so on. It is a structure array and I am not familiar with that.
Thanks for any advice, Ludek
Antworten (3)
Ludek
am 13 Jan. 2012
0 Stimmen
1 Kommentar
Chandra Kurniawan
am 13 Jan. 2012
for x = 1: 555
sourcefolders{x} = num2str(x,'%03i');
end
Ludek
am 13 Jan. 2012
0 Stimmen
1 Kommentar
Chandra Kurniawan
am 13 Jan. 2012
The use copyfile instead
for num = 1 : length(sourcefolders)
file = dir(fullfile(sourcefolders{num},filename));
newname = strcat(num2str(num,'%03i'),'.tif');
copyfile(fullfile(sourcefolders{num},file.name),fullfile(destinationfolder,newname));
end
Ludek
am 13 Jan. 2012
0 Stimmen
Kategorien
Mehr zu File Operations finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!