How to use Variables in movefile or copyfile ?
Mostra commenti meno recenti
Lets say I want to move or copy file from one folder to another. I am using movefile to do this, but the thing is that I want to automate this process. So I have a variable A = 'D:\Olddirectory\File.txt' which contains a path to my file and a variable B = 'D:\Newdirectory'. So the syntax says :
copyfile('D:\Olddirectory\File.txt','D:\Newdirectory');
% That way it works well, but when i use it this way:
copyfile([A,',',B]);
% which should give the same output
% it doesn`t work at all and give me an error: "Error using copyfile. No matching files were found."
I`ll be thankfull for any Help.
4 Commenti
Why do you have that comma between A and B? Try
copyfile(A,B)
copyfile(A,B,'f')
Pavlo M
il 30 Mag 2018
Paolo
il 30 Mag 2018
No worries, you can select Stephen's answer to accept the solution and close this question.
Stephen23
il 30 Mag 2018
"which should give the same output"
I don't see why that should give the same output: in the first case you call copyfile with two inputs, in the second you call it with just one input (and input that clearly does not follow any of the permitted syntaxes given in the documentation).
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su File Operations in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!