Here’s a script that mimics the way Autodesk Maya handles incremental saving of scene files.
Basically what it does is create a directory (if it is not already there) called incrementalSave in the directory your comp is located, in the incrementalSave directory another directory is created with the exact same name as your comp (including the extension)
Finally when both directories exist, the script copies your old scene file to the incrementalSave\compname directory and adds a 4 digit versioning number between the file name and the extension, separated by a ‘period’.
Every time you save, the directory structure is checked, and the script checks what the next highest versioning number should be, your old comp is copied, and the comp is saved (this way your final comp will always have the same name, where as you ‘backups’ are the only files that get incremented.)
The script has not been tested to death yet, so if you find anything, let me know.
Also, i have no idea whether or not this will play merry hell with Generations (as i have no idea whether or not Generations has a build in incremental saving system.)
Another thing you will notice is, that since this script copies the versioning file using the os.execute command, a DOS pop-up will appear for a couple of milliseconds, this is as far as i know, unavoidable, if someone however knows another way, please let me know.
Version 1.2 changelog:
- Changed the incremental save file pattern matching.
download : hos_incrementalSave_v1.2
.
--[[
hos_incrementalSave
by S.Neve / House of Secrets
some small updates from the inital release:
v1.2 changes:
- Changed the way the postfix increment number for the incremental backup comp
is searched for, as in the older version a name like 'vfx_shot_01_31-448.comp
would break the gsub expression for some unknown reason, returning a nil value.
v1.1 changes:
- creating the backup incremental file now uses the os.rename function to move
the file, this worked in Lightwave and seems to behave the same in Fusion,
this prevents the DOS box popup on saving.
- renamed the script to match our other script and plugin naming conventions.
- encapsulated the DOS file names in quotation marks to make creation in and
of directories with spaces possible.
v1.0 changes:
- Initial release
]]--
function findpattern(text, pattern, start)
return string.sub(text, string.find(text, pattern, start))
end
fa = composition:GetAttrs()
if fa.COMPS_FileName == "" then
Save()
else
pf = eyeon.parseFilename(MapPath(fa.COMPS_FileName))
if not direxists( pf.Path .. "incrementalSave" ) then
print("creating dir : " .. pf.Path .. "incrementalSave")
os.execute("mkdir \"" .. pf.Path .. "incrementalSave\"")
else
--print("dir exists")
end
if not direxists( pf.Path .. "incrementalSave\\" .. pf.Name .. pf.Extension ) then
print("creating dir : " .. pf.Path .. "incrementalSave\\" .. pf.Name .. pf.Extension)
os.execute("mkdir \"" .. pf.Path .. "incrementalSave\\" .. pf.Name .. pf.Extension .. "\"")
else
--print("dir exists")
end
-- search inc saves
path = pf.Path .. "incrementalSave\\" .. pf.Name .. pf.Extension .. "\\*.comp"
dir = readdir(path)
num = table.getn(dir)
currentVersion = 0
for i = 1,num do
if not dir[i].IsDir then
fileExtension = string.gsub( dir[i].Name, "[.][^.]*$", "")
--fileNumberString = string.gsub( fileExtension, string.gsub( fileExtension, "[^.][0-9]+$", ""), "")
fileNumberString = string.sub(fileExtension, string.find(fileExtension, "(%d+)$", 0))
fileNumber = tonumber( fileNumberString )
--print(fileNumberString)
--print(fileNumber)
if currentVersion < fileNumber then
currentVersion = fileNumber
end
end
end
currentVersionString = "000" .. tostring(currentVersion + 1)
currentVersionString = string.sub(currentVersionString, string.len(currentVersionString) - 3 , string.len(currentVersionString))
dest = pf.Path .. "incrementalSave\\" .. pf.Name .. pf.Extension .. "\\" .. pf.Name .. "." .. currentVersionString .. ".comp"
src = pf.Path .. pf.Name .. pf.Extension
os.rename(src, dest) -- this seems to work in Lightwave, and does the same in Fusion, much cleaner isn't it?
Save(src)
end
Version 1.1 changelog:
- Creating the backup incremental file now uses the os.rename function to move the file, this worked in Lightwave and seems to behave the same in Fusion, this prevents the DOS box popup on saving.
- Renamed the script to match our other script and plugin naming conventions.
- Encapsulated the DOS file names in quotation marks to make creation in and of directories with spaces possible.
download : hos_incrementalSave v1.1
.
--[[
hos_incrementalSave v1.1
by S.Neve / House of Secrets
some small updates from the inital release:
v1.1 changes:
- creating the backup incremental file now uses the os.rename function to move
the file, this worked in Lightwave and seems to behave the same in Fusion,
this prevents the DOS box popup on saving.
- renamed the script to match our other script and plugin naming conventions.
- encapsulated the DOS file names in quotation marks to make creation in and
of directories with spaces possible.
v1.0 changes:
- Initial release
]]--
fa = composition:GetAttrs()
if fa.COMPS_FileName == "" then
Save()
else
pf = eyeon.parseFilename(MapPath(fa.COMPS_FileName))
if not direxists( pf.Path .. "incrementalSave" ) then
print("creating dir : " .. pf.Path .. "incrementalSave")
os.execute("mkdir \"" .. pf.Path .. "incrementalSave\"")
else
--print("dir exists")
end
if not direxists( pf.Path .. "incrementalSave\\" .. pf.Name .. pf.Extension ) then
print("creating dir : " .. pf.Path .. "incrementalSave\\" .. pf.Name .. pf.Extension)
os.execute("mkdir \"" .. pf.Path .. "incrementalSave\\" .. pf.Name .. pf.Extension .. "\"")
else
--print("dir exists")
end
-- search inc saves
path = pf.Path .. "incrementalSave\\" .. pf.Name .. pf.Extension .. "\\*.comp"
dir = readdir(path)
num = table.getn(dir)
currentVersion = 0
for i = 1,num do
if not dir[i].IsDir then
fileExtension = string.gsub( dir[i].Name, "[.][^.]*$", "")
fileNumberString = string.gsub( fileExtension, string.gsub( fileExtension, "[0-9]+$", ""), "")
fileNumber = tonumber( fileNumberString )
if currentVersion < fileNumber then
currentVersion = fileNumber
end
end
end
currentVersionString = "000" .. tostring(currentVersion + 1)
currentVersionString = string.sub(currentVersionString, string.len(currentVersionString) - 3 , string.len(currentVersionString))
dest = pf.Path .. "incrementalSave\\" .. pf.Name .. pf.Extension .. "\\" .. pf.Name .. "." .. currentVersionString .. ".comp"
src = pf.Path .. pf.Name .. pf.Extension
os.rename(src, dest) -- this seems to work in Lightwave, and does the same in Fusion, much cleaner isn't it?
Save(src)
end
download : incrementalSave v1.0
.
-- incrementalSave v1.0
-- by S.Neve - House of Secrets 03-06-2009
-- for latest version, check http://www.svennneve.com
fa = composition:GetAttrs()
if fa.COMPS_FileName == "" then
Save()
else
pf = eyeon.parseFilename(MapPath(fa.COMPS_FileName))
if not direxists(pf.Path .. "incrementalSave") then
print("creating dir : " .. pf.Path .. "incrementalSave")
os.execute("mkdir " .. pf.Path .. "incrementalSave")
else
--print("dir exists")
end
if not direxists(pf.Path .. "incrementalSave\\" .. pf.Name .. pf.Extension) then
print("creating dir : " .. pf.Path .. "incrementalSave\\" .. pf.Name .. pf.Extension)
os.execute("mkdir " .. pf.Path .. "incrementalSave\\" .. pf.Name .. pf.Extension)
else
--print("dir exists")
end
-- search inc saves
path = pf.Path .. "incrementalSave\\" .. pf.Name .. pf.Extension .. "\\*.comp"
dir = readdir(path)
num = table.getn(dir)
currentVersion = 0
for i = 1,num do
if not dir[i].IsDir then
fileExtension = string.gsub( dir[i].Name, "[.][^.]*$", "")
fileNumberString = string.gsub( fileExtension, string.gsub( fileExtension, "[0-9]+$", ""), "")
fileNumber = tonumber( fileNumberString )
if currentVersion < fileNumber then
currentVersion = fileNumber
end
print( currentVersion )
end
end
currentVersionString = "000" .. tostring(currentVersion + 1)
currentVersionString = string.sub(currentVersionString, string.len(currentVersionString) - 3 , string.len(currentVersionString))
filename = pf.Path .. "incrementalSave\\" .. pf.Name .. pf.Extension .. "\\" .. pf.Name .. "." .. currentVersionString .. ".comp"
os.execute("copy /Y " .. fa.COMPS_FileName .. " " .. filename)
--Save(filename)
Save(pf.Path .. pf.Name .. pf.Extension)
end
Pingback: Fusion : hos_incrementalSave.eyeonscript update | svenneve.com