@echo off

rem		proj_name is the name of your project folder
rem 	If it contains a space, surround the whole name
rem 	with double quotes e.g. set proj_name="Tremendous Track"
set proj_name=example

rem 	btb_path is the location of the 'my projects' folder
rem		Double quotes are needed because 'my projects' contains a space
set btb_path="c:\programs\bobstrackbuilder\my projects"

rem		zpath is the location of the 7zip exexutable
set zpath="c:\programs\7-zip\7z.exe"

rem		Set the following variable to 1 if you want the date added to the 
rem 	filename of the backup
set add_date=0

rem		If a backup already exists, delete it.
rem		If the date is to be added, undated backups are not deleted,
rem		so you could make an undated backup at the start of the week
rem		and also have daily backups for each day.
rem		If you don't add the date, dated backups will not be deleted
rem     /=- replaces the / character (not allowed in filenames) with the - character
set today=%date:/=-%
if %add_date%==1 (
if exist %proj_name%_%today%.7z del %proj_name%_%today%.7z
) else (
if exist %proj_name%.7z del %proj_name%.7z
)

rem		Runs 7zip
rem		-xr!*.zip tells it to exclude all zip files
rem		.zip files will be XPacks, but you don't want to add them to every backup.
rem		Instead, a list of XPacks will be made, and if you need to restore a backup,
rem		you can put the XPacks back in afterwards
rem 	-xr!Thumbs.db tels it to also xclude Thumbs.db files. These are what Windows
rem 	uses to store thumbnails when browsing through folders
if %add_date%==1 (
%zpath% a %proj_name%_%today%.7z %btb_path%\%proj_name%\ -xr!*.zip -xr!Thumbs.db
) else (
%zpath% a %proj_name%.7z %btb_path%\%proj_name%\ -xr!*.zip -xr!Thumbs.db
)

rem		Adds the list of required XPacks to a text file
rem		The <nul line prevents a blank line being added at the end of the file
echo These zip files need to be placed in your project's "XPacks" folder: > %proj_name%_XPacks.txt
dir %btb_path%\%proj_name%\XPacks\ /a:-d /b >> %proj_name%_XPacks.txt
echo. >> %proj_name%_XPacks.txt
<nul (set/p z=You should be able to get them from your ...\BobsTrackBuidler\XPacks folder.) >> %proj_name%_XPacks.txt

rem		This puts the text file in the same archive as your backed up project
if %add_date%==1 (
%zpath% a %proj_name%_%today%.7z %proj_name%_XPacks.txt
) else (
%zpath% a %proj_name%.7z %proj_name%_XPacks.txt
)

rem		This deletes the text file as it is no longer needed
del %proj_name%_XPacks.txt

pause