[HELPER\TOOL] Small Batch file to rapidly copy and pack your mods.

The place to discuss scripting and game modifications for X4: Foundations.

Moderators: Scripting / Modding Moderators, Moderators for English X Forum

FlynTie
Posts: 36
Joined: Wed, 12. Dec 18, 01:42

[HELPER\TOOL] Small Batch file to rapidly copy and pack your mods.

Post by FlynTie »

Hey all,

It's fixed now, please redownload.

i made a small Batch file to aid me in the repetitive tasks during modding and i thought you guys might find it useful too.

Here is what it does.
I usually have my mods that i'm working on in a separate folder outside the X4 game directory.
Now every time i iterate on it i have to copy everything back to the extensions folder and since i'm on Win7 and just want to be safe (even tho i never had one problem so far) i have to pack them in a .cat (you guys know the drill).
This batch file automates that process for me and it works from every mod directory with whatever name your mod may have.

For those of you who don't want to download from Mega here is the batch file code.

Code: Select all

@echo OFF
:: ========================================================
:: This little Batch file lets you create .cat archives of your Mods and optionally copy it directly to your extension folder.
:: You need the XRCatTool.exe for it to work so download it at https://www.egosoft.com/download/x_rebirth/bonus_de.php?download=589
:: ========================================================

:: Set the directory of the XRCatTool.exe here
set XRCat="Y:\Modding\X4\XRebirthTools"

:: Directory of X4 Foundations (where the X4.exe is located)
set X4Dir="Y:\Games\X4 Foundations"

:: Do not edit anything beyond this point.
set Mdir=%~dp0
for %%a in ("%cd%") do set modname=%%~na

:: Run the XRCatTool and exlude any common unrelated file and the content.xml.
%XRCat%\XRCatTool -in %~dp0 -out ext_01.cat -exclude "content.xml" ".txt" ".bat" ".bak" ".cat" ".dat" -dump

:: Do we want to copy the files to the extensions folder?.
:choice
set /P c=Do you want to copy the Mod to your X4 extensions folder [Y/N]?
if /i "%c%" == "y" goto :copyfiles
if /i "%c%" == "n" goto :alldone
goto :choice

:: Copy files if the user wishes.
:copyfiles
robocopy %Mdir% %X4Dir%\extensions\%modname% *.cat *.dat content.xml /njh /njs

:: Clean up files, not yet first i need to implement a check that we're not in the extensions\modname folder. But you can use it if your mod environment is somewhere else.
:: It just cleans up the generated cat and dat files.
:: echo Cleaning up.
:: DEL *.cat
:: DEL *.dat

:: Aaand we're done.
:alldone
echo Ok then, we're all done here.
pause
There are two things you need to set before you can use it.
First thing is "XRCat" variable, this should point to the folder where the "XRCatTool.exe" is located, ie. "Y:\Modding\X4\XRebirthTools" this is where i have it.

Second thing that needs to be set is the "X4Dir" variable, this should point to the folder where the "X4.exe" is located, usually under "C:\Program Files (x86)\Steam\steamapps\common\X4 Foundations"
Small note: I do not have the game installed under "Program Files (x86)" since that created problems with other games in the past so i don't know if the current batch will properly copy everything.
If there are problems please let me know or anyone who knows about batch scripting feel free to contribute. :)

Possible future plans:
Auto delete unnecessary files after all is done. For Mod users only, so another choice maybe.
Detect if a subst_01.cat is needed. Afaik a few files are required to be in a subst cat.
Maybe directly zip it.
---------------------

I mainly did this for modders but it can be used by regular users too. Just execute the batch file in your mod folder and if it asks you to copy the files just say No. For now you need to clean up the mod directory yourself afterwards. Which means you can delete anything expect for the .cat and .dat files and the content.xml.

So last but not least here is the download for those who want it.
Mega.nz: https://mega.nz/#!qFk3AaoT!NRpwbfCNrFww ... 1Zl32spSnA

P.S: Let me know what you think and if there is anything that could be improved feel free to let me know, batch scripting isn't exactly my second nature.

That's it, have a good one and fly safe. o7
Last edited by FlynTie on Wed, 2. Jan 19, 20:36, edited 1 time in total.
contactr
Posts: 3
Joined: Wed, 27. Sep 17, 13:35
x4

Re: [HELPER\TOOL] Small Batch file to rapidly copy and pack your mods.

Post by contactr »

Very handy, thank you very much!
mrgrin
Posts: 9
Joined: Sat, 27. Nov 04, 00:13
x3tc

Re: [HELPER\TOOL] Small Batch file to rapidly copy and pack your mods.

Post by mrgrin »

Thanks for this. I am going to try it as I can't find any help on creating Cat/Dat files, and I have spent ages looking

Return to “X4: Foundations - Scripts and Modding”