How do I copy some files to another folder?

2 ビュー (過去 30 日間)
Jacopo Scarpellini
Jacopo Scarpellini 2022 年 8 月 11 日
編集済み: Stephen23 2022 年 8 月 11 日
I have a 10x1 string array which represents a list of files that I want to copy to a different folder
file_list =
10x1 string array
for j = 1:size(file_list,1)
copyfile file_list{j,:} destination_folder
end
I get the error
Error using copyfile
No matching files were found.
I guess the filename cannot be a string, but then what does it need to be?

採用された回答

Voss
Voss 2022 年 8 月 11 日
for j = 1:size(file_list,1)
copyfile(file_list(j),destination_folder)
end

その他の回答 (1 件)

Stephen23
Stephen23 2022 年 8 月 11 日
編集済み: Stephen23 2022 年 8 月 11 日
"I guess the filename cannot be a string..."
The filenames certainly can be string.
The problem is the you are using command syntax when you should be using function syntax:
copyfile(file_list(j),destination_folder)
% ^ ^ function syntax

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by