Arthur Fuller
fuller.artful at gmail.com
Tue Mar 18 20:31:29 CDT 2008
Whichever test you use, provided there is a goto then the other test is not required -- unless of course you have more than one branch, in which case you would need more than one IF since there is no equivalent to Select Case: if exist c:\autoexec.bat goto Yupper echo c:\autoexec.bat does not exist. echo Your mother wears army boots. echo Run as many commands here as you wish. When you're done... goto Done :yupper copy c:\autoexec.bat c:\autoexec.old echo Do something else. echo Do something else. goto Done <---- this, in this example, is redundant, since the next line is the Done label :Done echo That's all for now, folks. echo When you're ready for something really hip, ask me about for %x% in(). echo Batch languages are surprisingly powerful. Arthur On 3/18/08, Darren D <darren at activebilling.com.au> wrote: > > Brilliant > > Old timers Rule Arthur :-) - We all know the Old Bull/Young bull Story > Back to the Batch file Syntax > Would this be a valid syntax construct? - I should test for both > conditions - > yes? > ~~~~~~~~~~~~~~~~~~~~~~~~~~~ > IF NOT EXIST c:\autoexec.bat go to FileNotExist > IF EXIST c:\autoexec.bat go to FileExist > --OR Should I just continue with the batch file here rather than test for > EXIST > > FileExist: > Merge File Syntax here > > FileNotExist: > Copy file syntax here > ~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > > Many thanks > > Have a great day > > Darren > ----------------- > T: 1300 301 731 > > -----Original Message----- > From: accessd-bounces at databaseadvisors.com > [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Arthur Fuller > Sent: Wednesday, 19 March 2008 12:09 PM > To: Access Developers discussion and problem solving > Subject: Re: [AccessD] OT:Batch File Syntax > > If exist > is what you need. Here is an example: > > *IF EXIST c:\autoexec.bat echo Yupper > > *That is a simple example. For "echo Yupper", you can substitute something > like "copy x:\my.dll %windir%/my.dll". You could also get fancy, create a > label in the command file (e.g. a line that begins with a colon > immediately > followed by a label) and jump to it, like this: > > *IF EXIST c:\autoexec.bat goto mylabel > echo Nosireee > exit > > :mylabel > **echo Yupper > exit > * > > hth, > Arthur > (See? There are some advantages to being an old timer.) > > On 3/18/08, Darren D <darren at activebilling.com.au> wrote: > > > > Hi All > > > > > > > > Apologies for the Off Topic post - moderators let me know if this is too > > much of > > a stretch :-) > > > > I am calling a batch file that does many many things > > > > One of the things it does is 'merge' a file we have to a file the OS > > should have > > > > Sometimes the OS does not have this file So. > > > > I want to know the syntax in a batch file to test the existence of a > file > > and if > > it exists to "X" if it doesn't do "Y" > > > > > > > > > > > > Many thanks > > > > > > > > DD > > > > > > -- > > AccessD mailing list > > AccessD at databaseadvisors.com > > http://databaseadvisors.com/mailman/listinfo/accessd > > Website: http://www.databaseadvisors.com > > > > -- > > AccessD mailing list > AccessD at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/accessd > Website: http://www.databaseadvisors.com > > > -- > > AccessD mailing list > AccessD at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/accessd > Website: http://www.databaseadvisors.com >