Last active
December 19, 2015 09:19
-
-
Save 0x4a/5932253 to your computer and use it in GitHub Desktop.
Backup Total Commander Settings - requires Array.ahk and 7-zip - #ahk #backup #totalcmd
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#NoEnv | |
#SingleInstance, Force | |
; http://www.autohotkey.com/board/topic/45876-ahk-l-arrays/ | |
; not needed when placed in library folder | |
#Include <Array> | |
SetWorkingDir %A_ScriptDir% | |
; files to backup | |
files := Array() | |
files.append("wincmd.ini") | |
files.append("user.ini") | |
files.append("plugins.ini") | |
files.append("usercmd.ini") | |
files.append("wcx_ftp.ini") | |
files.append("sftpplug.ini") | |
files.append("tcignore.txt") | |
files.append("totalcmd.inc") | |
files.append("*.BAR") | |
; do not backup! | |
; files.append("history.ini") | |
timestamp = %A_YYYY%-%A_MM%-%A_DD%_-_%A_Hour%-%A_Min%-%A_SEC% | |
tmpDir = tmp_%timestamp% | |
archiveFilename = totalcmd-ini %timestamp% | |
; http://www.7-zip.org/ | |
archiveExe = "C:\Program Files\7-Zip\7z.exe" | |
closedTC = false | |
; check if script is run from total commander directory | |
if not FileExist(files[1]) | |
{ | |
Msgbox,,Error!, Files not found! `n`nScript must be run from `ntotal commander directory. `nPlease move accordingly! `n`nScript is terminating... | |
ExitApp | |
} | |
; check if total commander is running | |
if WinExist( "ahk_class TTOTAL_CMD" ) | |
{ | |
; offer to close total commander | |
Msgbox, 52,Close Total Commander?, Running Instance of Total Commander found! `nIf Total Commander is running `nyour backup will not be up to date. `n`nClose it? | |
Ifmsgbox Yes | |
{ | |
WinClose | |
closedTC = true | |
} | |
} | |
; make tmp dir | |
FileCreateDir, %tmpDir% | |
; copy files to tmp dir | |
Loop, % files.len() | |
FileCopy, % files[A_Index], %tmpDir% | |
; archive the files | |
SetWorkingDir %tmpDir% | |
RunWait, %archiveExe% a -t7z "%A_SCRIPTDIR%\%archiveFilename%.7z" * | |
; remove tmp dir | |
SetWorkingDir %A_ScriptDir% | |
FileRemoveDir, %TmpDir%, 1 | |
if (closedTC = "true") | |
{ | |
; restart TC | |
Msgbox,4,Finished,Your Settings were stored in %A_SCRIPTDIR%\%archiveFilename%.7z `n`nRestart Total Commander? | |
Ifmsgbox Yes | |
Run %A_SCRIPTDIR%\TOTALCMD.EXE | |
} | |
else | |
; no restart | |
Msgbox,,Finished,Your Settings were stored in %A_SCRIPTDIR%\%archiveFilename%.7z | |
ExitApp |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment