Changing the name of TXT file

4 ビュー (過去 30 日間)
Rica
Rica 2015 年 7 月 1 日
回答済み: Azzi Abdelmalek 2015 年 7 月 1 日
hi all, i have a big number of TEXT-Files. They are named like this: file_0,file_1..... Iwant to begin with 1 like:
file_1,file_2,..... is there any simple method to do this with matlab.
thank you

採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2015 年 7 月 1 日
YourFolder='C:\Documents and Settings\Mes documents\MATLAB'
f=dir(fullfile(YourFolder,'*.txt'));
g={f.name};
s=regexp(g,'\d+','match');
s= str2double([s{:}]);
[n,idx]=sort(s);
g=g(idx);
for k=numel(g):-1:1
fic=g{k};
fic1=regexprep(fic,num2str(n(k)),num2str(n(k)+1));
movefile(fullfile(YourFolder,fic),fullfile(YourFolder,fic1))
end

その他の回答 (1 件)

Martin Brown
Martin Brown 2015 年 7 月 1 日

カテゴリ

Help Center および File ExchangeString Parsing についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by