I have this simple file:
tags
home C:\Users\rodde
docs C:\Users\rodde\Documents
prev D:\
dt C:\Software\dt
The first column contains the tags, and the second column contains respective directories. Also, I have a program (dt.exe
) that expects a tag and prints to std::cout
a respective directory. For example, dt.exe docs
will output C:\Users\rodde\Documents
. Finally, I have a batch script dt.bat
@echo off
if [%*] == 1 (
rem Once here, we have no arguments.
rem Chdir to the previous directory.
dt.exe prev > directory.tmp
set DIR=<directory.tmp
dt.exe --update-prev %cd%
cd %DIR%
) else if [%1] == [-l] (
dt.exe -l
) else if [%1] == [-s] (
dt.exe -s
) else if [%1] == [-L] (
dt.exe -L
) else if [%1] == [-S] (
dt.exe -S
) else if [%1] == [-d] (
dt.exe -d
) else (
rem Once here, we have a tag, so chdir
rem to respective directory
dt.exe %1 > directory.tmp
set DIR=<directory.tmp
cd %DIR%
)
Unfortunately, this works only every 4th time or so.
What am I missing?
(The source code for dt.exe
is here.)