How can i open a list of files?

4 ビュー (過去 30 日間)
RADWAN A F ZEYADI
RADWAN A F ZEYADI 2022 年 8 月 31 日
回答済み: Voss 2022 年 8 月 31 日
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.

回答 (1 件)

Voss
Voss 2022 年 8 月 31 日
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

カテゴリ

Find more on Visual Exploration in Help Center and File Exchange

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by