Save each result in different folders
Afficher commentaires plus anciens
Hi I have 259 text file in a folder,P(1).txt:P(529).txt, and wanna change all their names to just P and save each one of then in a folder by their numbers, I could do it for one of them but when I got the code to for loop I got this error: ??? Error using ==> fprintf Invalid file identifier. Use fopen to generate a valid file identifier.
Error in ==> Untitled at 10
fprintf(fid2,'%s\n', str2{:});
any help will?
clc
clear
for i=2:530
fid1 = fopen(['P(' num2str(i-1) ').txt'],'r');
str1 = textscan(fid1,'%s','Delimiter','\n');
fclose(fid1);
OO=i-1
str2 = [str1{1}];
fid2 = fopen('E:\matlab\all\New folder\New folder (5)\VV\OO\P.txt','w');
fprintf(fid2,'%s\n', str2{:});
fclose(fid2);
end
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Entering Commands 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!