MATLAB: Extract name from file name extract name from file name dear all, i have file which name 200101010000-200101020000.dat..but i need to rename new file using 8 first digit (like 20010101.dat)..how i can extract the name and rename my new file? Best Answer curname = '200101010000-200101020000.dat';newname = curname([1:8 end-3:end]);movefile(curname, newname); Related SolutionsMATLAB: How to extract only file name from full file name Oh..I immediately get the answer:)The function, fileparts, can be used for this process:)file = 'H:\user4\matlab\myfile.txt';[pathstr,name,ext] = fileparts(file)Then the result ispathstr =H:\user4\matlabname =myfileext =.txt MATLAB: Variable name Best not to do that.http://matlab.wikia.com/wiki/FAQ#How_can_I_create_variables_A1.2C_A2.2C....2CA10_in_a_loop.3F Related QuestionFunction nameHow to extract file names.File names
Best Answer