-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMHWBackupper.bat
96 lines (87 loc) · 3.05 KB
/
MHWBackupper.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
rem You can remove all text above this line and run this again to set up a new .bat file.
@echo off
cls
for /F "usebackq tokens=3*" %%A IN (`reg query HKCU\Software\Valve\Steam /v SteamPath`) DO set usrdata=%%A %%B\userdata\
set usrdata=%usrdata:/=\%
if "%steamid%"=="" (
goto setid
) else (
goto main
)
:main
rem Get date & time and generate folder name:
set tmpvar=%date:~10,4%-%date:~4,2%-%date:~7,2% %time:~0,2%.%time:~3,2%.%time:~6,2%
if %tmpvar:~11,2% LSS 10 set tmpvar=%tmpvar:~0,11%0%tmpvar:~-7%
dir "%usrdata%%steamid%\582010" > nul || goto errornosource
dir "%backuplocation%\%tmpvar%" > nul && rd /s /q "%backuplocation%\%tmpvar%"
xcopy /e /h /i "%usrdata%%steamid%\582010" "%backuplocation%\%tmpvar%\save"
(
echo rd /s /q "%usrdata%%steamid%\582010"
echo xcopy /e /h /i save "%usrdata%%steamid%\582010"
echo msg /time:4 "%username%" Restore to %usrdata:)=^)%%steamid%\582010 was successful.
)>"%backuplocation%\%tmpvar%\restore.bat"
msg /time:4 "%username%" Backup to %backuplocation%\%tmpvar% was successful.
goto eof
:setid
echo This will generate a .bat file which will back up your Monster Hunter World save file to
echo a directory of your choosing. It will generate a new backup every time you run the
echo output .bat file and the directory will be timestamped like this:
echo.
echo 2018-08-20 13.53.08
echo.
echo This example backup was made on August 20, 2018 at 8 seconds past 1:53 PM.
echo.
echo In this directory will be a .bat file called "restore.bat". Run this file to restore the
echo backup from this directory.
echo.
echo Warning: Do not backup or restore while Monster Hunter World is running! Doing so could
echo corrupt your save! I'm not responsible if something goes wrong!
echo.
pause
echo.
set numfolders=0
for /f %%G in ('dir "%usrdata%*" /b') do (
set sid=%%~G
set /a numfolders=numfolders+1
)
if %numfolders%==2 (
set steamid=%sid%
echo SteamID3 auto-detected: %sid%
) else (
set choice=
set /p choice=You need to set the SteamID3. Launch https://steamidfinder.com to locate SteamID3? Y/N:
)
if /I "%choice%"=="Y" (
start /max https://steamidfinder.com
)
if "%steamid%"=="" set /p steamid=Type SteamID3:
echo.
echo You need to set the backup directory. Example: C:\Backups\Monster Hunter World
echo Do not use a trailing backslash.
echo.
set /p backuplocation=Type Backup Directory:
:outfile
echo.
if not '%outputfile%'=='' echo File already exists. Try again.
echo You need to set the output filename. (It must end in .bat or .cmd) Example: backupmhw.bat
echo.
set /p outputfile=Type Output Filename:
if exist %outputfile% goto outfile
goto makebat
:errornosource
echo Could not find source directory: "%usrdata%%steamid%\582010" Please rerun setup (MHWBackupper.bat)
goto eof
:makebat
(
echo @echo off
echo set steamid=%steamid%
echo set backuplocation=%backuplocation%
echo.
)>"%outputfile%"
TYPE %~nx0>>%outputfile%
:eof
set tmpvar=
set steamid=
set choice=
set numfolders=
set sid=