diff --git a/utils/general.py b/utils/general.py index b3253b112..86c584228 100755 --- a/utils/general.py +++ b/utils/general.py @@ -948,7 +948,7 @@ def increment_dir(dir, comment=''): dir = str(Path(dir)) # os-agnostic d = sorted(glob.glob(dir + '*')) # directories if len(d): - n = max([int(x[len(dir):x.find('_') if '_' in x else None]) for x in d]) + 1 # increment + n = max([int(x[len(dir):x.rfind('_') if '_' in Path(x).name else None]) for x in d]) + 1 # increment return dir + str(n) + ('_' + comment if comment else '')