Help needed with DOS commands for BAT file
Here is what I want to do with a BAT file in M2TW, the BAT file is placed in the mod's directory:
- Rename the main game's animation folder
- Start a mod
- Reverse the renaming after mod exit
Here is what I got so far:
Code:
@echo off
REM going up to main game level
cd ..\..
REM changing path to data folder and renaming the main game's animation folder
cd data
ren animations animations_backup
REM back to main game level
cd .\..
REM my standard universal batch file entry
IF EXIST kingdoms.exe (start kingdoms.exe @%0\..\Configuration.cfg) ELSE (
IF EXIST medieval2.exe (start medieval2.exe @%0\..\Configuration.cfg) ELSE (
echo ERROR: Cannot find the M2TW or Kingdoms executable.
echo You probably installed Bare Geomod into the wrong folder.
pause
)
)
REM pausing the file to wait for input from user after exit
echo Your input is required to reset a directory name
pause
REM reversing the renaming AFTER exiting the game
cd data
ren animations_backup animations
echo Reset is done
pause
This works fine but it does require user input which has to be assumed as unreliable. Is there the equivalent of a 'while' or 'wait' command in DOS that I can use instead?
The start command allows for a /wait switch but I did not manage to make it work because of the required command line, placing it after the exe or at the end crashed M2TW.
Edit: Using a 'timeout' should work: the generating of new animation files has finished by the time the first movie starts, so setting it to 20 should do the job.
Re: Helpl needed with DOS commands for BAT file
Man, I haven't fiddle with DOS commands in ages, so I had to launch the CommandPrompt in Windows just to rehearse what I once knew. :P
I think I know what's wrong and that's this.
Code:
rem going up to main game level
cd ..\..
rem changing to main game's data folder
cd data
In order to make the "cd data" command valid you must have a "data" directory present in the root level. Does there exist a "data" directory in the root level?
Where did you install M2TW, I mean what's the path for your M2TW installation setup?
You don't need to write the "cd ..\.." command like that when the "cd" command (I can't add a " \ " after "cd", but that's what I mean) does exactly the same thing.
Re: Help needed with DOS commands for BAT file
My test set up is Bare Geomod in a Steam custom installation, using the mod's BAT file:
D:\Steam\steamapps\common\Medieval II Total War\mods\bare_geomod\universal start.bat
I would need the full path if I wanted to change directly from the mod's folder to the game's data folder. That simply won't work other then on my machine hence I first went up two levels (from M2TW\mods\BG to M2TW) and then changed to the data sub folder (M2TW\data) present there:
cd ..\..
cd data
After that I went up one level again to M2TW to start executing the normal batch start:
cd .\..
Here is the final, working version using a 20 seconds timeout command (the new IDX\DAT files were generated in less then 10 seconds on my machine, but it's pretty fast):
Code:
@echo off
REM --- going up two levels to main game level
cd ..\..
REM --- going to the data subfolder and renaming the main game's animation folder
cd data
ren animations animations_backup
REM --- going back up one level to main game level
cd .\..
REM --- standard universal batch file
IF EXIST kingdoms.exe (start kingdoms.exe @%0\..\Configuration.cfg) ELSE (
IF EXIST medieval2.exe (start medieval2.exe @%0\..\Configuration.cfg) ELSE (
echo ERROR: Cannot find the M2TW or Kingdoms executable.
echo You probably installed Bare Geomod into the wrong folder.
pause
)
)
REM --- pausing the processing of commands for 20 seconds
timeout 20
REM --- reversing the renaming AFTER timeout has expired
REM !! no need to change levels, we are still at the main level
REM --- going to the data subfolder and renaming the main game's animation folder
cd data
ren animations_backup animations
Re: Help needed with DOS commands for BAT file
Re: Help needed with DOS commands for BAT file
Quote:
Here is the final, working version...
:tongue: