Jump to content

help to IF NOT EXIST batch command


Recommended Posts

It seems all of the methods work under certain conditions. Windows 98 native COMMAND.COM didn't understand (GOTO :NEXT)

but understood GOTO NEXT. WIN95CMD.EXE file understands both. So it seems certain flags/pipes/variables etc..,.. are recognized by both, but the WIN95CMD.EXE seems to recognize most if not all. Thanks guys, its working smoothly.

Link to comment
Share on other sites


Why could you not simply correct the first word after the equals symbol in each of the four cases I provided!

I think that it may be you who is misunderstanding OR!

You now seem to only want FILE.THREE to be deleted if both of the other two files do not exist.

IF NOT EXIST "FILE.ONE" (SET _=BO)
IF NOT EXIST "FILE.TWO" (SET _=%_%TH)
IF %_%==BOTH DEL "FILE.THREE"

So in summary:

  • IF BOTH FILE.ONE AND FILE.TWO DO NOT EXIST
    use the above example
  • IF AT LEAST ONE OF FILE.ONE OR FILE.TWO DO NOT EXIST
    use either of the two examples I provided in my original post

Link to comment
Share on other sites

Yzöwl did you look at post 14 it was the VBS way of doing what PROBLEMCHYLD wanted done.

If you read it and it really simple if the 2 files are not there then delete file 3, I am Dyslexic and could

understand what PROBLEMCHYLD wanted.

Yzöwl cool code :thumbup

Link to comment
Share on other sites

What is the value of %WinDir%? Does it have spaces?

The Windows folder can't have spaces so you don't need quotes (unless you set the variables manually to something else but it's not the case here). Microsoft themselves usually don't use quotes when pointing to %windir% / %systemroot% in their patches.

I usually suggest hardcoding paths to save headaches, especially for core files in C:\Windows\System ( Win9x ) or C:\Windows\System32 ( WinXP+ ). Earlier NT and 2K might have been in \WinNT but unless running on an older one is a real possibility, avoid it.

Newer Windows can also use WINNT, ex. when you upgraded your system from Windows 2000 to XP, later upgraded XP to Vista, and Vista to 7, etc.

Edited by tomasz86
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...