Jump to content

Change Backup Location


Recommended Posts

Can you change backup locations? I love that autoit backs up automatically, super cool feature as I have terrible saving/version/iteration habits. But is there any way to drop it to a folder instead of directly into script location? Basically I want to drop it to ..\backup instead of ..

Link to comment
Share on other sites

--------------------------------------------------------------------------------
-- OnBeforeSave(filename)
--
-- keep the number of backups as defined by backup.files = ?    by Jos van der Zande (JdeB)
--
-- AutoItTools.OnBeforeSave $(au3) 2 Alt+Shift+I Open Beta Include
--------------------------------------------------------------------------------
function AutoItTools:OnBeforeSave(filename)
    local sbck = tonumber(props['backup.files'])
    -- backup specified and bigger than 0 ?
    if sbck == nil or sbck == 0 then
        return false
    end
    local nbck = 1
    local bfil1 = ""
    if sbck > 1 then
        bfil1 = ".1"
    end
    -- check first file backup file format without number and rename it to *.1.bak
    if sbck > 1 and io.open (filename.. "." .. ".bak", "r") == nil and io.open (filename.. "." .. ".1.bak", "r") == nil then
        os.rename (filename .. ".bak", filename .. ".1.bak")
    end
    -- rename all files to +1
    while (sbck > nbck ) do
        local fn1 = sbck-nbck
        local fn2 = sbck-nbck+1
        os.remove (filename.. "." .. fn2 .. ".bak")
        os.rename (filename .. "." .. fn1 .. ".bak", filename .. "." .. fn2 .. ".bak")
        nbck = nbck + 1
    end
    -- rename original to .1.bak or .bak depending on number of backups
    os.remove (filename.. bfil1 .. ".bak")
    os.rename (filename, filename .. bfil1 .. ".bak")
    return false
end

I think I have to edit the AutoItTools.lua but I don't have any clue what to do.. I don't know how to program in .lua

 

Link to comment
Share on other sites

@Nine Sweet thanks! I saw that thread but he was talking about command prompts so I got scared off but it seems to work great.

For future googler's, see below.

Edited my 'C:\Program Files (x86)\AutoIt3\SciTE\lua\AutoItTools.lua' file to add the "perform_oscommand" function and modified the "AutoItTools:OnBeforeSave(filename)" function as listed in the comment below and it worked.

https://www.autoitscript.com/forum/topic/203221-scite-backup-copies/?do=findComment&comment=1461812

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...