[Script] Simply Backup Script

Post your working scripts, libraries and tools
User avatar
ScottMeyer
Posts: 29
Joined: 27 Sep 2017, 12:52
GitHub: ScottMeyer48
Contact:

[Script] Simply Backup Script

30 Oct 2017, 12:27

Hi,

simply save your scripts during construction.
all the "x" times with verification of the file modification

1) Add Simply_Backup_Script.ahk in your folder working

2) setup in the file:
- specify the script files to back up
- indicate the period

3) Launch

Ps: possibility backup manual press [SHIFT+F12]

improve your organization ;)
enjoy

Code :

Code: Select all

;	Simply_Backup_Script.ahk		write Scott Meyer 30/10/2017 (Freeware)
;	URL : https://autohotkey.com/boards/viewtopic.php?f=6&t=39182

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SetWorkingDir 	%A_ScriptDir%  ; Ensures a consistent starting directory.

; ##############################   ENTER HERE YOUR FILES TO BACKUP ##############################	Separate your files with ","
; #																								#
	Fichiers_a_Sauvegarder 	= 
; #					Exemple = My_New_Gui.ahk,Testing_Gui_Scroll_Argghh.ahk						#
; #																								#
; ##############################                DELAI              ##############################
; #																								#
	Delai = 600000		
; #			600000 for 5 Minutes - 900000 for 15 minutes - 1800000 for 30 minutes				#
; #																								#
; ###############################################################################################

IfNotExist		, %A_ScriptDir%\Backup
	FileCreateDir, %A_ScriptDir%\Backup

IfNotExist		, %A_ScriptDir%\Backup\Ressources
	FileCreateDir, %A_ScriptDir%\Backup\Ressources

if !FileExist(A_ScriptDir "\Backup\Ressources\Backup_icone.ico")
{
	UrlDownloadToFile, http://atelierludique.free.fr/000/UPLOAD/Backup_icone.ico, %A_ScriptDir%\Backup\Ressources\Backup_icone.ico 
	Sleep, 2000
}

if FileExist(A_ScriptDir "\Backup\Ressources\Backup_icone.ico")
	Menu, Tray, Icon, %A_ScriptDir%\Backup\Ressources\Backup_icone.ico

Info =

Loop	, parse, Fichiers_a_Sauvegarder, `,													; Count number Files
	Nb_de_Fichier = %A_Index%

SetTimer,BackUp,%Delai%				

; END SECTION READ 

~+F12::								; HOTKEY [SHIFT + F12] for backup manual
Manual = request
BackUp:
Loop, parse, Fichiers_a_Sauvegarder, `,
{
	StringTrimRight , Fichier_Sans_Extension	, A_LoopField	, 4							; removed extension file
	NomFinal 		= %Fichier_Sans_Extension%_%A_Now%.ahk									; Format futur name file
	
	FileGetTime		, Prendre_Date_Modification	, %A_LoopField%  							; Pick time file modification for compare
	IniRead			, Test_Date_Modification	,%A_ScriptDir%\Backup\Ressources\Backup.ini	,Tests_Modification	,%A_LoopField%	; If File not exist or Key return "ERROR"

	if Test_Date_Modification = ERROR 														; If not exist INI File or Key = Copy File and create INI
	{
		IniWrite	,%Prendre_Date_Modification%,%A_ScriptDir%\Backup\Ressources\Backup.ini	,Tests_Modification	,%A_LoopField%
		FileCopy	, %A_LoopField%				, %A_ScriptDir%\Backup\%NomFinal% 	, 1
		Info 		= %A_LoopField%`n
		continue
	}	

	If Test_Date_Modification <> %Prendre_Date_Modification%								; If File time modification is different then copy file
	{
		IniWrite	,%Prendre_Date_Modification%,%A_ScriptDir%\Backup\Ressources\Backup.ini	,Tests_Modification	,%A_LoopField%
		If Manual 	= request
		{
			NomFinal = %Fichier_Sans_Extension%_%A_Now%_Manual.ahk							; Format futur name file
			FileCopy, %A_LoopField%				, %A_ScriptDir%\Backup\%NomFinal%, 1
		}
		else
		{
			NomFinal = %Fichier_Sans_Extension%_%A_Now%_Auto.ahk							; Format futur name file
			FileCopy, %A_LoopField%				, %A_ScriptDir%\Backup\%NomFinal% 	, 1
		}
		Tmp 		= %A_LoopField%`n
		Info 		.= Tmp																	; Record all file saved 
		continue 
	}


	If ( A_Index = Nb_de_Fichier ) && ( Info <> "" )										; Last File checked and copy then show information
	{
		TrayTip		, Simply Backup Script		, Files saved : `n%Info%	, 10
		Info 		= 
		Manual 		=
		continue 
	}

	If ( A_Index = Nb_de_Fichier ) && ( Info = "" )											; Last File checked, no file copy then show information
	{
		TrayTip		, Simply Backup Script		, No File to save  			, 10
		Manual 		=
	}	
}	
return
JEE (jeeswg) "Better WinGetPos" : LIEN Forum AHK
AHK Vision Go : LIEN Forum AHK
Simply Backup Script : LIEN Forum AHK

Return to “Scripts and Functions”

Who is online

Users browsing this forum: wsimon98 and 53 guests