Skip to content
Snippets Groups Projects
Commit aa57fb79 authored by Eugenio Pignataro's avatar Eugenio Pignataro
Browse files

Fix incremental save

parent cfc5f457
No related branches found
No related tags found
No related merge requests found
...@@ -49,15 +49,15 @@ class saveIncremental(Operator): ...@@ -49,15 +49,15 @@ class saveIncremental(Operator):
def execute(self, context): def execute(self, context):
filepath = bpy.data.filepath filepath = bpy.data.filepath
if filepath.count("_v"): if os.path.basename(filepath).rpartition(".")[0][-5:].count("_v"):
strnum = filepath.rpartition("_v")[-1].rpartition(".blend")[0] strnum = filepath.rpartition("_v")[-1].rpartition(".blend")[0]
intnum = int(strnum) intnum = int(strnum)
modnum = strnum.replace(str(intnum), str(intnum + 1)) modnum = "%02d" % (intnum+1)
output = filepath.replace(strnum, modnum) output = filepath.replace(strnum, modnum)
basename = os.path.basename(filepath) basename = os.path.basename(filepath)
bpy.ops.wm.save_as_mainfile( bpy.ops.wm.save_as_mainfile(
filepath=os.path.join(os.path.dirname(filepath), "%s_v%s.blend" % filepath=os.path.join(os.path.dirname(filepath), "%s_v%s.blend" %
(basename.rpartition("_v")[0], str(modnum)))) (basename.rpartition("_v")[0], str(modnum))))
else: else:
output = filepath.rpartition(".blend")[0] + "_v01" output = filepath.rpartition(".blend")[0] + "_v01"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment