some times when I save File it doesn't save !!!
actually it saves but not in my file . it saves with a strange name in other file !
please see the video.
save with these names

SOLVED!
I forgot to close first file



Moderators: Víctor Paredes, Belgarath, slowtiger
Code: Select all
function DV_Incremental_Save:Run(moho)
local path = moho.document:Path()
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()
else
local OS1 = package.config:sub(1,1)
if OS1 ~= "/" then
OS1 = "\\"
end
local name = moho.document:Name()
local file = io.open(path, "rb")
local source_content = file:read("*all")
local version_number = 1
local file_name_part = string.gsub(name,".moho", "")
local dir_part = string.gsub(path,name, "")
local backup_folder = dir_part..file_name_part.. [[ Incremental Saves]] ..OS1
os.execute( "mkdir ".. '"' .. backup_folder .. '"' )
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(path..name)
moho:FileSave()
moho:Click()
end
end
very intelligent improve I see that in maya too. even when rendering it create a copy of file and renders that for prevent changing scene during render.Víctor Paredes wrote: ↑Wed Nov 10, 2021 11:55 pm To make the saving process safer and avoid the 0k files' issue sometimes appeared, when you save, 13.5.2 saves a copy of the file first. Once that saving is complete, Moho replaces the old file with the new one.
This process is normally extremely quick, but it can vary depending on how heavy the file is.
We made this change to be sure that if anything goes wrong with the software or the computer while saving, users won't lose their files.
just my mistake .synthsin75 wrote: ↑Thu Nov 11, 2021 1:44 am Why does file:close have an argument? You only need an argument when using the syntax io.close(path).
because I want to store a copy of file before current saving. its easy if just save with increment name in current folder. but when i want to save backups in another folder it's become tricky. i have to copy my file before saving changes and working file name must stay same as before.synthsin75 wrote: ↑Thu Nov 11, 2021 1:44 am And why are you writing the content of the file, instead of just saving it to a new name?
hi victor.Víctor Paredes wrote: ↑Wed Nov 10, 2021 11:55 pm To make the saving process safer and avoid the 0k files' issue sometimes appeared, when you save, 13.5.2 saves a copy of the file first. Once that saving is complete, Moho replaces the old file with the new one.
This process is normally extremely quick, but it can vary depending on how heavy the file is.
We made this change to be sure that if anything goes wrong with the software or the computer while saving, users won't lose their files.
ScriptInterface:FileSaveAs(path) can save with the same file name to a different location, defined in the path.davoodice2 wrote: ↑Thu Nov 11, 2021 8:59 ambecause I want to store a copy of file before current saving. its easy if just save with increment name in current folder. but when i want to save backups in another folder it's become tricky. i have to copy my file before saving changes and working file name must stay same as before.synthsin75 wrote: ↑Thu Nov 11, 2021 1:44 am And why are you writing the content of the file, instead of just saving it to a new name?
please Notice: We must store file before any changes we made. FileSaveAs or save cant do thesesynthsin75 wrote: ↑Thu Nov 11, 2021 5:42 pmScriptInterface:FileSaveAs(path) can save with the same file name to a different location, defined in the path.davoodice2 wrote: ↑Thu Nov 11, 2021 8:59 ambecause I want to store a copy of file before current saving. its easy if just save with increment name in current folder. but when i want to save backups in another folder it's become tricky. i have to copy my file before saving changes and working file name must stay same as before.synthsin75 wrote: ↑Thu Nov 11, 2021 1:44 am And why are you writing the content of the file, instead of just saving it to a new name?
And you can reopen the original file using ScriptInterface:FileOpen(path).
Sure they can, if you use them before any changes. Just like copying and writing the data before changes.davoodice2 wrote: ↑Thu Nov 11, 2021 7:24 pm please Notice: We must store file before any changes we made. FileSaveAs or save cant do these
Wes! I speak about incremental save!synthsin75 wrote: ↑Thu Nov 11, 2021 8:06 pmSure they can, if you use them before any changes. Just like copying and writing the data before changes.davoodice2 wrote: ↑Thu Nov 11, 2021 7:24 pm please Notice: We must store file before any changes we made. FileSaveAs or save cant do these
I am too.davoodice2 wrote: ↑Thu Nov 11, 2021 9:15 pmWes! I speak about incremental save!synthsin75 wrote: ↑Thu Nov 11, 2021 8:06 pm Sure they can, if you use them before any changes. Just like copying and writing the data before changes.![]()