How can I convert an absolute path to a relative path in batch? I have an absolute path to a directory `A` and a reference directory `B`, and I need the path to `A` relative to `B`. As example, the following batch script should print `..\other\somedir\`.

```
setlocal enabledelayedexpansion
set referencePath=C:\Users\xyz\project\
set absolutePath=C:\Users\xyz\other\somedir\
set relativePath=...
echo %relativePath%

```

I tried `relativePath=!absolutePath:%referencePath%=!`, but this yields the absolute path `C:\Users\xyz\other\somedir\`.

I need something similar to the python function `os.path.relpath`:

```
>>> os.path.relpath("C:\\Users\\xyz\\other\\somedir", "C:\\Users\\xyz\\project\\")
"..\\other\\somedir"

```

I need this because I have a batch file with command line arguments similar to the above file names. This batch file creates another batch file `startup.bat` which sets some environment variables and starts an application. The `startup.bat` may be called over network, so I have to use relative paths. With absolute paths, the environment variables would point to the files on the wrong machine.