How can i open a list of files?

9 visualizaciones (últimos 30 días)
RADWAN A F ZEYADI
RADWAN A F ZEYADI el 31 de Ag. de 2022
Respondida: Voss el 31 de Ag. de 2022
Hi,
i am trying to convert some files by GUI from extension to another and i would like to have the converted file with same name of the original file for a list of files in the same directory?
any suggestions please,thanks in advance.

Respuestas (1)

Voss
Voss el 31 de Ag. de 2022
folder = 'Path\to\your\directory';
old_ext = '.txt'; % original extension
new_ext = '.dat'; % new extension
old_files = dir(fullfile(folder,['*' old_ext])); % files with extension old_ext in folder
old_names = fullfile(folder,{old_files.name}); % full-path names of those files
new_names = regexprep(old_names,[old_ext '$'],new_ext); % new file names with extension new_ext

Categorías

Más información sobre Dialog Boxes en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by