This is a small batch script that would be stored in the game directory. It allows you to sync the local DF folder with a remote DF folder. The purpose is to transfer saved games to other machines. Since I play DF on three machines (desktop, laptop, work desktop) it became important to keep them all the same. It will only attempt to transfer new information, and won't overwrite otherwise. It will not automatically backup/restore the seasonal auto-backup saves, only the main region folders. You will also need GetTime.cmd from [1] and either put it in your system32 dir or the dwarf fortress folder. To acctually use the script, you'll need to send two parameters to it. The first will be the location of the dwarf fortress folder on the local machine and the second is the folder on the remote machine. Whenever it pulls or pushes information from that remote source, will will log the name of the machine and the time at which is started and finished. The script will automatically display the most recent entry for you so that you know what the status is.
[show]Code
|
@echo off
title Dwarf Fortress
set localdir=%~1
set remotedir=%~2
net use "%remotedir%"
cls
if not exist "%remotedir%" goto error
:menu
if "noremote"=="1" goto skipstatus
echo Last recorded command to source:
setLocal EnableDelayedExpansion
for /f "tokens=* delims= " %%a in (%remotedir%\dfortress.log) do (
set var=%%a
)
echo !var!
endlocal
echo.
:skipstatus
echo 1) Pull, Launch, Push
echo 2) Launch
echo 3) Pull
echo 4) Push
echo 5) Exit
choice /C:12345 /N ?:
echo.
if %errorlevel%==1 goto full
if %errorlevel%==2 goto launch
if %errorlevel%==3 goto pull
if %errorlevel%==4 goto push
if %errorlevel%==5 goto exit
cls
echo Invalid Choice
echo.
goto menu
::
:: Full Cycle
::
:full
if "noremote"=="1" goto error
set full=1
echo Running full cycle...
call :pull
call :launch
call :push
goto exit
::
:: Pull
::
:pull
if "noremote"=="1" goto error
title Dwarf Fortress - Pulling
echo Bringing up changes from server...
call gettime
echo %_time% : %computername% - Pull - Start >> "%remotedir%\dfortress.log"
robocopy "%remotedir%" "%localdir%" * /Z /E /PURGE /XF gamelog.txt *.log /XD *-spr-* *-sum-* *-aut-* *-win-* > "%localdir%\dfortress-pull.log"
call gettime
echo %_time% : %computername% - Pull - End >> "%remotedir%\dfortress.log"
echo Done.
if "%full%"=="1" goto :eof
choice /C:yn /N Do you want to play? [y/n]:
if %errorlevel%==1 goto launch
if %errorlevel%==2 goto exit
::
:: Launch
::
:launch
title Dwarf Fortress - Running
echo Launching Dwarf Fortress...
cd /d "%localdir%"
start /wait dwarfort.exe
if "%full%"=="1" goto :eof
choice /C:yn /N Do you want to push your changes? [y/n]:
if %errorlevel%==1 goto push
if %errorlevel%==2 goto exit
::
:: Push
::
:push
if "noremote"=="1" goto error
title Dwarf Fortress - Pushing
echo Pushing changes back to server...
call gettime
echo %_time% : %computername% - Push - Start >> "%remotedir%\dfortress.log"
robocopy "%localdir%" "%remotedir%" * /Z /E /PURGE /XF gamelog.txt *.log /XD *-spr-* *-sum-* *-aut-* *-win-* > "%localdir%\dfortress-push.log"
call gettime
echo %_time% : %computername% - Push - End >> "%remotedir%\dfortress.log"
echo Done.
if "%full%"=="1" goto :eof
goto exit
::
:: Exit
::
:exit
echo Goodbye
exit
::
:error
::
echo The following remote directory is not available, you will only be able to 'Launch'
echo %remote%
set noremote=1
pause
goto menu
|