Error using copyfile (Cannot copy or move a file or directory onto itself)
28 次查看(过去 30 天)
显示 更早的评论
I am trying to copy a file with name test_0 and paste it in same location with name test_1. Then i want to repeat this code with the numbers increasing by one in the file name. I wrote this code:
for i=1:100
Filename=strcat('test_',num2str(i));
Filename=strcat(Filename,'.xlsx');
FilenameR=strcat('test_',num2str(i-1));
FilenameR=strcat(FilenameR,'.xlsx');
copyfile (FilenameR),(Filename)
end
and i am getting an error:
Error using copyfile
Cannot copy or move a file or directory onto itself.
Error in File (line 19)
copyfile (FilenameR),(Filename)
What can i do.
3 个评论
Stephen23
2020-2-6
"I think the syntax is just supposed to be copyfile FilenameR Filename"
Nope, that won't work:
采纳的回答
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Startup and Shutdown 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!