Craft The World Guide

Batch file that backups save games before game is launched for Craft The World

Batch file that backups save games before game is launched

Overview

Has your save game ever become corrupted? You thought the game crashed and restarted it right away to find your world empty? The save and the bak had 20 kb and the version saved in recent files in windows was at least a day old. A free day you played a lot. This small guide shows how to make a small batch file that backups your saves when launching the game and how to compile it and use the executale to still be able to launch the game from inside steam.

General description

This script will create a backup of your Craft the World save games before the Game is launched. If you have Winrar installed it will create compressed archives and if not uncompressed folders using the system date and time as the name. It should work for any language and date format. The result will look like this ctw-YYYYMMDD-HHMMSS so they will be sorted correctly using windows file explorer. It will keep 5 backups and delete all older ones. This number can be changed by editing the keep variable at the beginning of this script. The backups will be located in C:UsersAppDataRoamingdekovir and contain all your saved worlds.
Compiled to an executable it will even backup your saved games if the game is launched from inside steam or by using the desktop or startmenu icons created by the game.
It will check how you are using it and if its saved to the right location. No changes should be needed because it uses relative paths.
This script will work with Vista or Server 2008 or any newer version of Windows.

Usage as batch file

To use it as a batch file go to your Craft the World program folder. This folder is located in …SteamSteamAppscommonCraftTheWorld
The default location for Steam is in C:Program Files (x86)Steam
Create a new text file and paste the script. Then rename it to CraftWorld.bat. Now right-click it and create a shortcut. This can be copied to any location in your system to start the game. This is the safest way to use the script but will only make backups if you use this shortcut to start the game. When launched from inside steam or by using the shortcuts created by the game itself no backups will be created.

Usage as an executable

This is a bit tricky but it will create a backup evertime the game is launched from within steam or by using the original shortcuts created when installing the game.
You have to compile this bat to an exe. I used the bat to exe converter from F2KO which can be found here: [link] or any other converter you trust. It only compiled this script using 64 bit and I had to use UPX compression to stop Avast from identifing it as malware. To use it please go to your Craft the World folder and rename the executable CraftWorld.exe to ctw.exe and then copy the compiled exe into the same folder. It has to be called CraftWorld.exe to work.
This also has a small drawback. Every time the game updates or if you let steam check the game files it will overwrite the compiled bat. In this case you will have to rename the game exe to ctw.exe again and also copy the compiled exe into the game folder again. So keep a backup somewhere! 😉

I don’t think this will result in a ban because it doesn’t tamper with any security measures and any cheat protected game would delete the compiled exe right away. But before steam allows this use it at our own risk. I have been running it for at least a week and nothing happend.

Script

echo off :: Number of backups to keep :: 0 no backups will be created :: 1 will keep all backups :: 2 or higher will keep set number of backups set keep=5 set startmode= “” :: check if the batch or compiled version is used and if the bat or compiled version are copied to the right location If exist ctw.exe ( if exist CraftWorld.exe ( if exist CraftWorld_steam.pdb ( set startmode=exe call :backup ) ) ) if exist CraftWorld.exe ( if exist CraftWorld.bat ( if exist CraftWorld_steam.pdb ( set startmode=steamlink call :backup ) ) ) echo ************************************************************************* echo * This script will create a backup of your Craft the World save games * echo * before the Game is launched. If you have Winrar installed it will * echo * create compressed archives and if not uncompressed folders using the * echo * system date and time as the name. It should work for any language and * echo * date format. The result will look like this ctw-YYYYMMDD-HHMMSS so * echo * they will be sorted correctly using windows file explorer. It will * echo * keep 5 backups and delete all older ones. This number can be changed * echo * by editing the keep variable at the beginning of this script. * echo * * echo * You can use it by just copying this bat into your Craft the World * echo * folder. Then right-clicking it to create a shortcut which can be * echo * started from anywhere in your system. This is the safest way but will * echo * not create backups if the game is launched from inside steam or by * echo * clicking the desktop or startmenu icon created by the game. * echo * * echo * To create backups when launching the game from inside steam or by * echo * using the original icons you have to compile this bat to an exe. * echo * I used the bat to exe converter from F2KO which can be found here: * echo * [link] or any other converter you trust. * echo * It only compiled this script using 64 bit and I had to use UPX * echo * compression to stop Avast from identifing it as malware. * echo * To use it please go to your Craft the World folder and rename the * echo * executable CraftWorld.exe to ctw.exe and then copy the compiled exe * echo * into the same folder. It has to be called CraftWorld.exe to work. * echo * This folder is located in …SteamSteamAppscommonCraftTheWorld * echo * The default location for Steam is in C:Program Files (x86)Steam * echo * The backups will be located in * echo * C:UsersAppDataRoamingdekovir * echo * and contain all your saved worlds. * echo ************************************************************************* pause call :end :backup if %keep%== 0 call :launch :: Create Backupname for /F “usebackq tokens=1,2 delims==” %%i in (`wmic os get LocalDateTime /VALUE 2^>NUL`) do if ‘.%%i.’==’.LocalDateTime.’ set ldt=%%j set ldt=%ldt:~0,4%%ldt:~4,2%%ldt:~6,2%-%ldt:~8,2%%ldt:~10,2%%ldt:~12,2% set backupname=ctw-%ldt% set /a keep=%keep%-1 :: Check if Winrar is installed in C:Program Files (x86) IF EXIST “C:Program Files (x86)WinRAR” ( :: delete old backups for /F “tokens=* skip=%keep%” %%I In (‘dir %appdata%dekovirctw*.* /A-D /B /O-D /TW’) do ( echo+ echo DELETING OLD BACKUP SET %appdata%dekovir%%~I del “%appdata%dekovir%%~I” ) :: Create new backup C:”Program Files (X86)”WinRARrar a /r /ep1 %appdata%dekovir%backupname% %appdata%dekovircrafttheworld call :launch ) :: Check if Winrar is installed in C:Program Files IF EXIST “C:Program FilesWinRAR” ( :: delete old backups for /F “tokens=* skip=%keep%” %%I In (‘dir %appdata%dekovirctw*.* /A-D /B /O-D /TW’) do ( echo+ echo DELETING OLD BACKUP SET %appdata%dekovir%%~I del “%appdata%dekovir%%~I” ) :: Create new backup C:”Program Files”WinRARrar a /r /ep1 %appdata%dekovir%backupname% %appdata%dekovircrafttheworld call :launch ) :: delete old backup folders for /F “tokens=* skip=%keep%” %%I In (‘dir %appdata%dekovirctw*.* /AD /B /O-D /TW’) do ( echo+ echo DELETING OLD BACKUP SET %appdata%dekovir%%~I rd /s /q “%appdata%dekovir%%~I” ) :: Create new backup folder robocopy %appdata%dekovircrafttheworld %appdata%dekovir%backupname%CraftTheWorld /e /dcopy:t /nfl /ndl call :launch :launch if %startmode%== exe ( ctw.exe call :end ) if %startmode%== steamlink ( start steam://rungameid/248390 call :end ) :end exit
SteamSolo.com