Computing.Net > Forums > Disk Operating System > If exist doesn't work

If exist doesn't work

Reply to Message Icon

Original Message
Name: solano
Date: May 31, 2008 at 12:02:21 Pacific
Subject: If exist doesn't work
OS: dos
CPU/Ram: 4gb
Model/Manufacturer: amd
Comment:

echo off
if exist C:\Documents and Settings\solano\Bureau\file.xlsx goto MESSAGE
echo The file C:\Documents and Settings\solano\Bureau\file.xlsx doesn't exist
Pause
goto END
MESSAGE
echo The file C:\Documents and Settings\solano\Bureau\file.xlsx exists

Pause
:END


Report Offensive Message For Removal


Response Number 1
Name: dtech10
Date: May 31, 2008 at 16:19:06 Pacific
Reply: (edit)

Hi

Try quotes around it

if exist "C:\Documents and Settings\solano\Bureau\file.xlsx"


Report Offensive Follow Up For Removal

Response Number 2
Name: DosX
Date: May 31, 2008 at 16:27:40 Pacific
Reply: (edit)

The filename has got spaces. Try to put it in quotes i.e.:

@echo off
if exist "C:\Documents and Settings\solano\Bureau\file.xlsx" goto MESSAGE
echo The file C:\Documents and Settings\solano\Bureau\file.xlsx doesn't exist
Pause
goto END
:MESSAGE
echo The file C:\Documents and Settings\solano\Bureau\file.xlsx exists
Pause
:END


BTW, you forgot to put ":" before MESSAGE label.


Report Offensive Follow Up For Removal

Response Number 3
Name: Bicephale
Date: June 3, 2008 at 09:50:04 Pacific
Reply: (edit)

Full path FileNames of the form
"C:\Documents and Settings\" are
implying that this is a Windows
console problem and hence you're
not posting in the proper forum.

¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
Salutations,

Michel Samson
a/s Bicéphale


Report Offensive Follow Up For Removal

Response Number 4
Name: mavis007
Date: June 4, 2008 at 10:44:54 Pacific
Reply: (edit)

IF EXIST c:\path\filename.ext goto lable1
IF NOT EXIST c:\path\filename.ext goto lable2

:LABLE1
echo filename exists
goto lable3

:LABLE2
echo filename does not exist
goto lable4

:LABLE3
pause
:: type commands here
goto exit

:LABLE4
pause
:: type commands here
goto exit

:EXIT

Grrrr
wat do I know?
... got brain freeze


Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: If exist doesn't work

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software




Have you ever used OpenOffice?

Yes, as my main suite.
Yes, occationally.
Yes, but only once.
No, never.


View Results

Poll Finishes In 4 Days.
Discuss in The Lounge