필터 지우기
필터 지우기

Fastest way to copy files on Windows

조회 수: 9 (최근 30일)
Joe_Z
Joe_Z 2020년 5월 22일
댓글: Rik 2020년 5월 22일
I am interested in the fastest way to copy files from one directory to another in MATLAB on Windows platform. I have two questions, one about the quickest way and the second about how memory is used in MATLAB which is why I did not just go ahead and test this myself.
A file structure driveA: main_folder > subfolders > files.ext could be copied by
% 1) Copy entire main folder
copyfile('driveA:\main_folder', 'driveB:\main_folder');
% 2) parallel copy the subfolders
subfolders = dir('driveA:\main_folder\*'); % ignoring . and .. for now
parfor i = 1:length(subfolders)
copyfile(fullfile(subfolders(i).folder, subfolder(i).name), ...
fullfile('driveB', subfolder(i).name));
end
% 3) parallel copy every individual file
files = dir('driveA:\main_folder\*\*.ext')
parfor i = 1:length(files)
path_split = strsplit(files(i).folder, filesep);
path_no_drive = path_split(2:end);
copyfile(fullfile(files(i).folder, files(i).name), ...
fullfile('driveB', path_no_drive, files(i).name));
end
Q1: is there likely to be much difference in performance, particularly between methods 2 and 3?
Q2: the reason I did not test this myself is I have a feeling that when repeating copying files, if repeating a copyfile procedure the files copy much faster if they have been copied recently, as if they were still held in memory. Is this is the case?
Thanks for your help
  댓글 수: 1
Rik
Rik 2020년 5월 22일
About your second question: that depends on the storage medium you're using. Most drives will use some form of caching. If the files are still in the cache, the writing will be much faster.
I doubt there will be much difference between these three methods, although the second and third might trigger multiple threads of the file transfer, which would speed up the copying.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Parallel Computing에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by