Skip to content

Instantly share code, notes, and snippets.

@BrynM
Last active January 24, 2023 18:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BrynM/b2fc0280878c57899ca4519d8e53615f to your computer and use it in GitHub Desktop.
Save BrynM/b2fc0280878c57899ca4519d8e53615f to your computer and use it in GitHub Desktop.
NMS Save Backup Batch File
Put the batch file in your HelloGames directory and create a shortcut to use it
on your desktop or something. On my windows machine, that directory is something
like `C:\Users\BrynM\AppData\Roaming\HelloGames`.
You'll also need a `zip` program in your `$PATH` such as 7zip (https://www.7-zip.org/).
@echo off
setlocal ENABLEDELAYEDEXPANSION
REM User settings
set nmsSaveDir=NMS
set outDir=%nmsSaveDir%_backups
REM Automated settings
set goodDate=!date:~10,4!!date:~4,2!!date:~7,2!
set timestamp=%goodDate%_%time::=.%
echo Timestamp: %timestamp%
set outFile=NMS_%timestamp%.zip
REM Do things and stuff.
if not exist %outDir% ( echo Creating directory "%outDir%"... ) && ( mkdir %outDir% )
echo Checking "%outDir%\%outFile%"...
if exist %outDir%\%outFile% goto failsafe
echo Zipping "%outDir%\%outFile%"...
REM Let's keep backups but remember how the option is used.
REM zip -r9 %outDir%\%outFile% %nmsSaveDir% -x %nmsSaveDir%?Backup*
( zip -r9 %outDir%\%outFile% %nmsSaveDir% ) && ( echo Writing "%outDir%\%outFile%" complete. )
goto ending
REM GOTO! HAHA!
:failsafe
echo Error - File "%outDir%\%outFile%" exists^^!
echo Aborted^^!
pause
:ending
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment