MATLAB: Delete lines n to m in many text files MATLABmatlab text Hello there, I have 500 text files with names R1.txt to R500.txt. How can delete lines 5002 to 5012 from all the text files and save them in the same text files? Many thanks. Best Answer folder = '???'for iFile = 1:500 % Create file name: File = fullfile(folder, sprintf('R%d.txt', iFile)); % Import file and modify the contents: DataC = strsplit(fileread(File), '\n'); DataC(5002:5012) = []; % Overwrite the file: fid = fopen(File, 'w'); if fid == -1 error('Cannot open file for writing: %s', File); end fprintf(fid, '%s\n', DataC{:}); fclose(fid);end Related SolutionsMATLAB: I want to delete all the headerlines and delimiters from the data in the below attached text file The best solution is probably to read your entire file as text, then remove the header lines, then parse them with textscan. MATLAB: How can i upload video folder and cut it into frames For a single video, this is the procedure.https://in.mathworks.com/matlabcentral/answers/48797-how-to-extract-frames-of-a-videoOnce you are thorough with single video, then you can run a loop for each video and achieve the task. You can see below link on how to access all files in a folder:https://in.mathworks.com/matlabcentral/answers/224348-how-can-i-read-all-text-files-in-a-folder-without-making-a-structThe above link explains for text files, you can use your video format instead of .txt. Related QuestionDelete empty line in .dat file.To read a text file using matlab
Best Answer