Image
-- **************************************************
-- Provide Moho with the name of this script object
-- **************************************************
--v2 add eparate folder for save
--2.1  add sound
--v2.2 fix bug
--v2.3 change name of script , add Auto save 
--v2.4 change name of script , add Auto save 
--v2.5 fix contain - in name
ScriptName = "DV_Backup"

-- **************************************************
-- General information about this script
-- **************************************************

DV_Backup = {}


function DV_Backup:Name()
	return "BackUp File"
end


function DV_Backup:Version()
	return "2.5"
end


function DV_Backup:Description()
	return ("Back Up File")
end


function DV_Backup:Creator()
	return "davood tabatabaei (davoodice)"
end


function DV_Backup:UILabel()
	return("DV Backup ".. self:Version())
end

function DV_Backup:IsEnabled(moho)

	return true
end




function DV_Backup:Run(moho)    
local path = moho.document:Path()
::goin::
if (path == "") then     
    local alert =  LM.GUI.Alert(LM.GUI.ALERT_WARNING,
                MOHO.Localize("/Scripts/tool/SaveIncrement/FirstSave=Please save your file"),
                nil,
                nil,
                MOHO.Localize("/Scripts/OK=OK"),
                MOHO.Localize("/Scripts/CANCEL=CANCEL"),
                nil)
            if alert == 1 then       
                do return end 
            end    
    moho.FileSave() 
local path = moho.document:Path()	
else
   local OS1 = package.config:sub(1,1)
    if OS1 ~= "/" then
     OS1 = "\\"
     end  
   local name = moho.document:Name()

   local file = io.open(path, "rb")
   if(file==nil or file=="") then 
		path = ""
		goto goin
   end
   local source_content = file:read("*all")
   file:close()
   local version_number = 1 

   local file_name_part = string.gsub(name,".moho", "")
   local i = string.match(path,".*()\\") --last \
	
   local dir_part = string.sub(path,1, i)
--	print(dir_part)

   local backup_folder = dir_part..file_name_part.. [[ Backups]] ..OS1
   
   	file = io.open(backup_folder .."\\".. "temp", "wb") 
	if(not file) then
		os.execute( "mkdir ".. '"' .. backup_folder .. '"' )
	else
		file:close()
	end
   
  
  local path = backup_folder
    moho:BeginFileListing(path)
	local fileName = moho:GetNextFile()
    while fileName ~= nil do
		sepPos = string.find(fileName, ".", 1, true)
		if (sepPos ~= nil) then
			local extn = string.sub(fileName, sepPos + 1)
			if (extn == "moho") then        
                local corr = string.find(fileName, "_%d+.moho")  
                if (corr ~= nil) then  
                        local current = tonumber(string.match(string.match(fileName, "_%d+.moho"), "%d+"))
                        if( current >= version_number) then
                            version_number = current+1
                        end
                end           
            end
        end  
        fileName = moho:GetNextFile()
    end   
local new = file_name_part .. '_'..version_number..'.moho'
file = io.open(path..new, "wb")
file:write(source_content)
file:close()
moho:Click()   
moho:FileSave()  

           
end
end

Icon
DV AutoSave (With Incremental Backup)
Listed

Script type: Button/Menu

Uploaded: Mar 19 2022, 10:08

automatically save project and make a backup from previous save.
automatically save project and make a backup from previous save.
you can adjust time intervals and permit before backup in option of script. also you can backup with increment manually with click on toolbar buttonĀ 
it creates a folder next to your moho file.
its better if Your images not be in the same folder as the moho file.

Installation Options:

This script, and all other scripts on this site are distributed as free software under the GNU General Public License 3.0 or later.
Downloads count: 124