Rename multiple files in consecutive order

4 ビュー (過去 30 日間)
Steffen Eisele
Steffen Eisele 2021 年 4 月 6 日
コメント済み: Steffen Eisele 2021 年 4 月 7 日
Hi I have 22 folders, each containing data named 00001.gen to 01460.gen. I need to combin those in to a single folder and name the consecutively, meaning 00001.gen to 32120.gen. Any one out there who can help me?
  2 件のコメント
Matt J
Matt J 2021 年 4 月 6 日
編集済み: Matt J 2021 年 4 月 6 日
What decides the order in which the 22 folders are concatenated?
Steffen Eisele
Steffen Eisele 2021 年 4 月 7 日
The 22 folders represent data from 22 consecutive years.

サインインしてコメントする。

採用された回答

Jan
Jan 2021 年 4 月 6 日
Do the 22 folders have a common base folder? If so:
SrcFolder = 'C:\Your\Base\Folder\'; % Parent folder of the 22 folders
DestFolder = 'C:\Your\Destination\Folder\';
if ~isfolder(DestFolder)
mkdir(DestFolder);
end
List = dir(fullfile(, '**', '*.gen');
for iFile = 1:numel(List)
Src = fullfile(List(iFile).folder, List(iFile).name);
Dest = fullfile(DestFolder, sprintf('%05d.gen', iFile));
copyfile(Src, Dest);
end
  1 件のコメント
Steffen Eisele
Steffen Eisele 2021 年 4 月 7 日
Yest they have a common base folder. I'll try your code. Thanks for your help.

サインインしてコメントする。

その他の回答 (0 件)

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by