making multiple copies of a file
Afficher commentaires plus anciens
I would like to make multiple copies of a file each of which will have a different name. example: source file: A.txt copies A1.txt, A2.txt... How can I use copyfile and be able to do this? Thanks for inputs
Réponse acceptée
Plus de réponses (3)
Amith
le 26 Déc 2012
0 votes
will this work
copyfile('output2.txt',destnames(i));
1 commentaire
Walter Roberson
le 26 Déc 2012
No, destnames here is a cell array of strings, so destnames(i) would be a 1 x 1 cellarray, rather than a string. If you used destnames{i} then that would be a string.
You would need to loop "i" over all of the output string possibilities. The cellfun() that I show is responsible for that.
Diana Krupnik
le 28 Jan 2019
0 votes
This solution names the files by numbering them, would it be possible to instead change the names based on a table that contains string or text?
Sam Apoola
le 14 Fév 2019
This worked for me
% loop for creating 100 copies
n=100;
for i=1:n
jobname{i}= ['copy', num2str(i),'.txt'];
copyfile('original.txt',jobname{i});
end
Catégories
En savoir plus sur Cell Arrays dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!