I have a number of text files in a directory. I want to copy the contents of each of these text files into brand new text files except I do not want to copy the first 4 lines. For this I have written this code but it is not working. Can you help me fix this?
files = dir('*.TXT')N = numel(files)count = 0;for i = 1:N fid1 = files(i).name disp(fid1) a = fopen(fid1,'r') file_name = [sprintf('%1.0f',i) '.txt']; fopen(file_name,'w+'); for K = 1:4 inline = fgetl(a) end while ischar(inline) inline = fgetl(a) fprintf(file_name,'%s\n\r',inline) end fclose('all')end
Best Answer