MATLAB 复制文件

RPATH_SCALE1_IMG = 'F:\background\images';
RPATH_SCALE2_IMG = 'F:\background\sampleimage';
RPATH_SCALE3_IMG = 'F:\background\sampleimage3';
RPATH_SCALE1_LAB = 'F:\background\label';
RPATH_SCALE2_LAB = 'F:\background\samplelabel';
RPATH_SCALE3_LAB = 'F:\background\samplelabel3';
DPATH_SCALE1 = 'F:\background\scale1';
DPATH_SCALE2 = 'F:\background\scale2';
DPATH_SCALE3 = 'F:\background\scale3';
fprintf('Copy the trian file and test file to 3 scale fold\n');
train_img = dir('F:\background\train80\*.jpg');
test_img = dir('F:\background\test80\*.jpg');
train_txt = dir('F:\background\trainlabel80\*.txt');
test_txt = dir('F:\background\testlabel80\*.txt');
for i=1:length(train_img)
    train_name = train_img(i).name;
    train_txt_name = train_txt(i).name;
    copyfile([RPATH_SCALE1_IMG,'\',train_name],[DPATH_SCALE1,'\','train','\',train_name]);
    copyfile([RPATH_SCALE2_IMG,'\',train_name],[DPATH_SCALE2,'\','train','\',train_name]);
    copyfile([RPATH_SCALE3_IMG,'\',train_name],[DPATH_SCALE3,'\','train','\',train_name]);
    copyfile([RPATH_SCALE1_LAB,'\',train_txt_name],[DPATH_SCALE1,'\','trainlabel','\',train_txt_name]);
    copyfile([RPATH_SCALE2_LAB,'\',train_txt_name],[DPATH_SCALE2,'\','trainlabel','\',train_txt_name]);
    copyfile([RPATH_SCALE3_LAB,'\',train_txt_name],[DPATH_SCALE3,'\','trainlabel','\',train_txt_name]);
end
for i=1:length(test_img)
    test_name = test_img(i).name;
    test_txt_name = test_txt(i).name;
    copyfile([RPATH_SCALE1_IMG,'\',test_name],[DPATH_SCALE1,'\','test','\',test_name]);
    copyfile([RPATH_SCALE2_IMG,'\',test_name],[DPATH_SCALE2,'\','test','\',test_name]);
    copyfile([RPATH_SCALE3_IMG,'\',test_name],[DPATH_SCALE3,'\','test','\',test_name]);
    copyfile([RPATH_SCALE1_LAB,'\',test_txt_name],[DPATH_SCALE1,'\','testlabel','\',test_txt_name]);
    copyfile([RPATH_SCALE2_LAB,'\',test_txt_name],[DPATH_SCALE2,'\','testlabel','\',test_txt_name]);
    copyfile([RPATH_SCALE3_LAB,'\',test_txt_name],[DPATH_SCALE3,'\','testlabel','\',test_txt_name]);
end

你可能感兴趣的:(Matlab)