BAT file and "IF EXIST"

Questions about Wine on Linux
Locked
N. de Jonge
Newbie
Newbie
Posts: 2
Joined: Sun Aug 04, 2013 5:59 pm

BAT file and "IF EXIST"

Post by N. de Jonge »

I have a test.bat file:

Code: Select all

@echo off
set TEST=%~dp0test.bat
echo %TEST%
if not exist {%TEST%} (
  echo test.bat not found
  exit /b 1
)
When I run this, the output is:
$ wine cmd
Wine CMD Version 5.1.2600 (1.6)
Z:\home\ndejonge>test.bat
Z:\home\ndejonge\test.bat
test.bat not found
Does anyone know why it says test.bat is not found, even though right before that it displays the exact location of test.bat?

I start: Z:\home\ndejonge>test.bat

It says %TEST% is: Z:\home\ndejonge\test.bat

But then suddenly "if not exist {%TEST%}" is true.

Thanks.
lahmbi5678
Level 7
Level 7
Posts: 823
Joined: Thu Aug 27, 2009 6:23 am

Re: BAT file and "IF EXIST"

Post by lahmbi5678 »

Hi,

are you sure, that you need the curly brackets? I just tried your example, without the curly brackets it seems to work.
N. de Jonge
Newbie
Newbie
Posts: 2
Joined: Sun Aug 04, 2013 5:59 pm

Re: BAT file and "IF EXIST"

Post by N. de Jonge »

lahmbi5678 wrote:[...], without the curly brackets it seems to work.
Thanks, that fixed the problem.
Locked