Skip to content

Commit 4a73511

Browse files
authored
Merge pull request #64 from Unity-Technologies/UNI-22474-better-file-number-increment
UNI-22474 better file name increment
2 parents 89e1d19 + 239c128 commit 4a73511

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

Assets/FbxExporters/Editor/ConvertToModel.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,17 @@ private static string IncrementFileName(string path, string filename)
170170
string ext = Path.GetExtension (filename);
171171

172172
int index = 1;
173+
174+
// try extracting the current index from the name and incrementing it
175+
var result = System.Text.RegularExpressions.Regex.Match(fileWithoutExt, @"\d+$");
176+
if (result != null) {
177+
var number = result.Value;
178+
if (int.TryParse (number, out index)) {
179+
fileWithoutExt = fileWithoutExt.Remove (fileWithoutExt.LastIndexOf (number));
180+
index++;
181+
}
182+
}
183+
173184
string file = null;
174185
do {
175186
file = string.Format ("{0} {1}{2}", fileWithoutExt, index, ext);

0 commit comments

Comments
 (0)