Search code examples
windowsbatch-fileziprarxpi

How to create xpi from a batch script


I wanted to automate the process of creating xpi using winrar with pwd being used instead of passing the current dir from outisde.

@REM ------- BEGIN xpi.bat ----------------
@setlocal
@echo off
set path="C:\Program Files\WinRAR\";%path%

winrar.exe a -afzip -r -ep1 %PWD%/MYaddon.xpi %PWD%

REM ------- END xpi.bat ------------------

Edit : So here is the final batch:

@REM ------- BEGIN xpi.bat ----------------
@setlocal
@echo off
set path="C:\Program Files\WinRAR\";%path%
erase "%CD%\MyAddon.xpi"
winrar.exe a -afzip -r -ep1 "%CD%\MyAddon.xpi" "%CD%/*"

REM ------- END xpi.bat ------------------

Solution

  • Use "%CD%\MYaddon.xpi".

    • In windows, to retrieve the current directory, the %CD% variable is used.

    • Windows can handle slashes as directory separator, but not all programs running in windows do, so, it is better to use backslashes.