source: trunk/src/rename_indexing.m @ 1086

Last change on this file since 1086 was 1078, checked in by sommeria, 13 months ago

various updates

File size: 719 bytes
1% add an index to a name, or increment an existing index, if the proposed Name (char string) already exists in the list ListName (cell)
2function NewName = rename_indexing(Name,ListName)
6while ~isempty(detectname)
7    detectname=find(strcmp(NewName,ListName),1);%test the existence of the proposed name in the list
8    if detectname% if the name already exist
9        rr=regexp(NewName,'(\d+)$'); %look for numerical indexing at the end of NewName
10        if isempty(rr)
11            NewName=[NewName '_1'];%add the index 1
12        else
13            newindex=str2num(NewName(rr:end))+1; %increment the index by 1
14            NewName=[NewName(1:rr-1) num2str(newindex)];
15        end
16    end
Note: See TracBrowser for help on using the repository browser.