Guest yawnmoth Posted August 26, 2007 Posted August 26, 2007 Say I have the following *.cmd file: @echo off cd some_directory cd .. If I run it and some_directory exists, nothing will happen - I'll be in the same directory as before. If, however, some_directory doesn't exist, it'll take me back to the parent directory. My question is.. how can I change this behavior? How can I make it so that if some_directory doesn't exist, it doesn't do "cd .."? Maybe I could do some sort of if statement and do the "cd .." conditionally?
Guest HeyBub Posted August 26, 2007 Posted August 26, 2007 Re: stopping a batch file when an error occurs? yawnmoth wrote: > Say I have the following *.cmd file: > > @echo off > > cd some_directory > cd .. > > If I run it and some_directory exists, nothing will happen - I'll be > in the same directory as before. If, however, some_directory doesn't > exist, it'll take me back to the parent directory. > > My question is.. how can I change this behavior? How can I make it > so that if some_directory doesn't exist, it doesn't do "cd .."? Maybe > I could do some sort of if statement and do the "cd .." conditionally? IF ERRORLEVEL...
Guest spamsucks@tiscali.co.uk Posted August 27, 2007 Posted August 27, 2007 Re: stopping a batch file when an error occurs? On 26 Aug, 06:45, yawnmoth <terra1...@yahoo.com> wrote: > Say I have the following *.cmd file: > > @echo off > > cd some_directory > cd .. > > If I run it and some_directory exists, nothing will happen - I'll be > in the same directory as before. If, however, some_directory doesn't > exist, it'll take me back to the parent directory. > > My question is.. how can I change this behavior? How can I make it > so that if some_directory doesn't exist, it doesn't do "cd .."? Maybe > I could do some sort of if statement and do the "cd .." conditionally? IF Exist C:\some_directory ( echo yes ) ELSE ( echo no )
Recommended Posts