GLBasic forum

Codesnippets => Macros => Topic started by: Schranz0r on 2009-Jul-29

Title: Backup-Manager for GLBasic :)
Post by: Schranz0r on 2009-Jul-29
This is a Backup-Manager on a macro (batchfile).
It use a menu to do some stuff :D

If you use it, you have to edit a line:

SET backuppath=C:\GLB_Backups

for example:

SET backuppath=D:\MyStuff\GLB_Backups

The full MACRO:

Code (glbasic) Select
:: Backupmanager

@ECHO OFF

:: Set the backuppath (you can edit it!)
SET backuppath=C:\GLB_Backups

:start
CLS
ECHO Backupmanager by -Schranz0r- www.glbasic.com
ECHO.
ECHO [1] save and exit
ECHO [2] save and open backupfolder
ECHO [3] open backupfolder
ECHO [0] close
ECHO.
ECHO -------------------------------
ECHO.

set /P menu="select what you want to do: "

IF /I "%menu%" == "1" GOTO save_exit
IF /I "%menu%" == "2" GOTO save_open
IF /I "%menu%" == "3" GOTO open
IF /I "%menu%" == "0" GOTO close
IF /I "%menu%" == "" GOTO start



:: ------------------------------------------------------------------ SAVE & EXIT -
:save_exit

:: clear the screen
CLS

:: Display some stuff on the console ;)
ECHO Copy project %GLB_PROJ_NAME% to %backuppath%\%GLB_PROJ_NAME%

:: Create the directory for the backup if it not exist
IF NOT EXIST "%backuppath%\%GLB_PROJ_NAME%\" MKDIR "%backuppath%\%GLB_PROJ_NAME%\"

:: Copy the project to th backup-folder
XCOPY "%GLB_PROJ_PATH%\*.*" "%backuppath%\%GLB_PROJ_NAME%\" /E/Y

:: wait for a keyhit
PAUSE
EXIT /B



:: ------------------------------------------------------------------- SAVE & OPEN -
:save_open

:: clear the screen
CLS

:: Display some stuff on the console ;)
ECHO Copy project %GLB_PROJ_NAME% to %backuppath%\%GLB_PROJ_NAME%

:: Create the directory for the backup if it not exist
IF NOT EXIST "%backuppath%\%GLB_PROJ_NAME%\" MKDIR "%backuppath%\%GLB_PROJ_NAME%\"

:: Copy the project to th backup-folder
XCOPY "%GLB_PROJ_PATH%\*.*" "%backuppath%\%GLB_PROJ_NAME%\" /E/Y

:: open the explorer and go to the backupfolder
%SystemRoot%\explorer.exe /e,%backuppath%

:: exit the batchfile (Macro)
EXIT /B


:: ------------------------------------------------------------------------- OPEN -
:open

:: clear the screen
CLS

:: open the explorer and go to the backupfolder
%SystemRoot%\explorer.exe /e,%backuppath%

:: exit the batchfile (Macro)
EXIT /B


:: ------------------------------------------------------------------------ CLOSE -
:close

CLS
EXIT /B
Title: Re: Copy your project to a backupfolder
Post by: Moru on 2009-Jul-29
Nice, if you download the latest beta from the frontpage, macro is working for english users too.
Title: Re: Copy your project to a backupfolder
Post by: Schranz0r on 2009-Jul-29
Thx for the info ;)

I update the first post and add some stuff  :whistle:
Title: Re: Backup-Manager for GLBasic :)
Post by: Hemlos on 2009-Oct-16
Thanks Schranzor,

I altered your code a little to make it work for my computer a little better.

Code (glbasic) Select
:: Backupmanager

@ECHO OFF

:: Set the backuppath (you can edit it!)
color 1F
md Backup
SET backuppath=%GLB_PROJ_PATH%\Backup

:start
CLS
TITLE Backupmanager For GLBasic
ECHO.
ECHO [1] save and exit
ECHO [2] save and open backupfolder
ECHO [3] open backupfolder
ECHO [0] close
ECHO.
ECHO -------------------------------
ECHO.

set /P menu="select what you want to do: "

IF /I "%menu%" == "1" GOTO save_exit
IF /I "%menu%" == "2" GOTO save_open
IF /I "%menu%" == "3" GOTO open
IF /I "%menu%" == "0" GOTO close
IF /I "%menu%" == "" GOTO start



:: ------------------------------------------------------------------ SAVE & EXIT -
:save_exit

:: clear the screen
CLS

:: Display some stuff on the console ;)
ECHO Copy project %GLB_PROJ_NAME% to %backuppath%

:: Copy the project to the backup-folder
COPY "%GLB_PROJ_PATH%\*.*" "%backuppath%"

:: wait for a keyhit
PAUSE
EXIT /B



:: ------------------------------------------------------------------- SAVE & OPEN -
:save_open

:: clear the screen
CLS

:: Display some stuff on the console ;)
ECHO Copy project %GLB_PROJ_NAME% to %backuppath%\%GLB_PROJ_NAME%

:: Copy the project to th backup-folder
COPY "%GLB_PROJ_PATH%\*.*" "%backuppath%"

:: open the explorer and go to the backupfolder
%SystemRoot%\explorer.exe /e,%backuppath%

:: exit the batchfile (Macro)
EXIT /B


:: ------------------------------------------------------------------------- OPEN -
:open

:: clear the screen
CLS

:: open the explorer and go to the backupfolder
%SystemRoot%\explorer.exe /e,%backuppath%

:: exit the batchfile (Macro)
EXIT /B


:: ------------------------------------------------------------------------ CLOSE -
:close

CLS
EXIT /B