-
Notifications
You must be signed in to change notification settings - Fork 0
/
AutoProfileSwitcher.bat
182 lines (182 loc) · 5.25 KB
/
AutoProfileSwitcher.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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
::Initialize - set title and window properties, load parameters, etc.
:Initialize
@ECHO OFF
mode con: cols=35 lines=8
setlocal enabledelayedexpansion
set Headed=1
if %1%.==. goto ERROR
if %1%==/help goto ABOUT
if %1%==/a goto ADDNEW
if %1%==/h goto HEADLESS
set Game=%1
call :READINI AutoProfileSwapper.ini %Game% SaveDir SaveDir
set insection=
call :READINI AutoProfileSwapper.ini %Game% SaveFldr SaveFldr
goto OPEN
::
:ABOUT
mode con: cols=110 lines=28
echo Changes a game's current savegame profile, if the game does not allow such options
echo.
echo AutoProfileSwapper.bat [^/a ^| ^/h] [GameID] [SaveDir] [SaveFldr]
echo.
echo /a -------- Add a new game to the config file.
echo /h -------- Headless mode. Automatically switch profiles without user interaction.
echo GameID ---- Loads the selected Game from the Config file.
echo When used with /a, adds the game ID to config file.
echo SaveDir --- Requires /a. Adds the specified folder as the location of gamesaves folder.
echo Example: If Game1's savedata is at C:\Games\Game1\Saves\save01.sav
echo SaveDir should be C:\Games\Game1
echo SaveFldr -- Requires /a. Adds the specified folder as the target folder for creating multiple profiles.
echo This folder contains the Savedata.
echo Example: If Game1's savedata is at C:\Games\Game1\Saves\save01.sav
echo SaveFldr should be Saves
echo.
echo Usage:
echo.
echo AutoProfileSwapper.bat /h Game1
echo Switches profile for Game1 without user input
echo AutoProfileSwapper.bat Game1
echo Displays Current profile for Game1 and Asks user if they would like to switch.
echo AutoProfileSwapper.bat /a Game1 C:\Games\Game1 Saves
echo Adds Game1 as a new game in config file, with savegame folder set to C:\Games\Game1\Saves
echo AutoProfileSwapper.bat /a
echo Gives a prompt to add a new game to the config file.
echo.
pause
cls
exit
::
::Opening error "game not found"
:ERROR
echo Error! Game %Game% not found!
echo Exiting in 5 seconds...
ping -n 6 localhost >nul
goto END
::
::Get info from INI file
:READINI <filename> <section> <key> <result>
set %~4=
setlocal
set insection=
for /f "usebackq eol=: tokens=*" %%a in ("%~1") do (
set line=%%a
if defined insection (
for /f "tokens=1,* delims==" %%b in ("!line!") do (
if /i "%%b"=="%3" (
endlocal
set %~4=%%~c
goto :eof
)
)
)
if "!line:~0,1!"=="[" (
for /f "delims=[]" %%b in ("!line!") do (
if /i "%%b"=="%2" (
set insection=1
) else (
endlocal
if defined insection goto :eof
)
)
)
)
endlocal
::
::Opening sequence
:OPEN
title %Game% Detected
cd /d %SaveDir%
type ".\%SaveFldr%\Profile.txt"
if %Headed%==0 goto SWAP
set/p "pro=Swap Profile? ('Y'es/'N'o) "
if %pro%==y goto SWAP
if %pro%==Y goto SWAP
if %pro%==n goto END
if %pro%==N goto END
echo Invalid choice.
goto OPEN
::
::Swapping function
:SWAP
if %Headed%==0 (
echo Swapping Profile...
ping -n 11 localhost >nul
)
ren "%SaveFldr%" "%SaveFldr%_"
ren "%SaveFldr%Profile2" "%SaveFldr%"
ren "%SaveFldr%_" "%SaveFldr%Profile2"
if %Headed%==0 goto END
goto OPEN
::
::Headless Mode
:HEADLESS
mode con: cols=35 lines=9
set Headed=0
shift
set Game=%1
call :READINI AutoProfileSwapper.ini !Game! SaveDir SaveDir
set insection=
call :READINI AutoProfileSwapper.ini !Game! SaveFldr SaveFldr
goto OPEN
::
::Add a new GameID to Config File
:ADDNEW
::Check if GameID Exists
set Game=%2
for /f "tokens=1,* delims=[]" %%x in (AutoProfileSwapper.ini) do (
call :IDFOUND %%x
)
::if not exists, Create!
mode con: cols=35 lines=9
echo.>>AutoProfileSwapper.ini
echo ^[%2^]>>AutoProfileSwapper.ini
echo ^:^:%2 Profile - Auto Added>>AutoProfileSwapper.ini
echo SaveDir="%3">>AutoProfileSwapper.ini
echo SaveFldr=%4>>AutoProfileSwapper.ini
cd /d %3
echo ===================================>.\%4\Profile.txt
echo The Active Profile is>>.\%4\Profile.txt
echo ----------------------------------->>.\%4\Profile.txt
echo Profile Name Here>>.\%4\Profile.txt
echo ----------------------------------->>.\%4\Profile.txt
echo %2>>.\%4\Profile.txt
echo ===================================>>.\%4\Profile.txt
md %4Profile2
echo ===================================>.\%4Profile2\Profile.txt
echo The Active Profile is>>.\%4Profile2\Profile.txt
echo ----------------------------------->>.\%4Profile2\Profile.txt
echo Profile Name Here>>.\%4Profile2\Profile.txt
echo ----------------------------------->>.\%4Profile2\Profile.txt
echo %2>>.\%4Profile2\Profile.txt
echo ===================================>>.\%4Profile2\Profile.txt
type .\%4\Profile.txt
echo New GameID Added!
pause
goto END
::
::Test all GameIDs vs new GameID and stop from creating again
:IDFOUND
if %Game%==%1 (
mode con: cols=35 lines=8
cls
echo =================================
echo Error: Game already exists!
echo -----------------------------
echo GameID = %1
echo Run this program without "/a"
echo =================================
echo Exiting in 5 seconds...
ping -n 6 localhost >nul
goto END
) else ( goto :eof )
::
::Exit program
:END
if %Headed%==0 (
cls
type ".\%SaveFldr%\Profile.txt"
echo Profile swapped. Exiting...
ping -n 11 localhost >nul
)
exit