Effacer les filtres
Effacer les filtres

How can i open a list of files?

4 vues (au cours des 30 derniers jours)
RADWAN A F ZEYADI
RADWAN A F ZEYADI le 31 Août 2022
Réponse apportée : Voss le 31 Août 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.

Réponses (1)

Voss
Voss le 31 Août 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

Catégories

En savoir plus sur Dialog Boxes dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by