Filenames in MATLAB - directory

4 ビュー (過去 30 日間)
Matthew Worker
Matthew Worker 2020 年 9 月 25 日
編集済み: N/A 2020 年 9 月 30 日
Hello,
So currently, what I'm doing it's prompting out window to select folder, I then was thinking of using a foor loop that goes through every file inside the folder, changes the filename and saves it within the same location.

回答 (1 件)

Ameer Hamza
Ameer Hamza 2020 年 9 月 25 日
Something like this
d = uigetdir(pwd, 'Select a folder');
files = dir(fullfile(d, '*.s2p'));
for i = 1:numel(files)
original_name = fullfile(files(i).folder, files(i).name);
new_name = strrep(original_name, ' ', '_');
movefile(original_name, new_name)
end

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by