If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Need DOS help
Hi folks,
I'm writing a batch file and need to check for the presence of a folder. I find that the "IF EXIST ...." syntax only works for text in WinME. I can use this in WinXP but NOT in ME IF EXIST C:\TEST GOTO END :START RENAME C:\START\SAMPLE.TXT JONES.TXT GOTO DONE :END ERASE C:\TEST\XXXX.TXT YYYY.TXT GOTO DONE ONE EXIT Running this batch file in WinXP works fine but in WinME it does NOT follow the directions. It simply drops to the next line after the IF EXIST statement. Same thing happens if I use IF NOT EXIST - just goes to the nest line. Can someone advise on how to check if a folder is there and how to jump to one or more places in the batch file for other actions? Thanks, Fred |
#2
|
|||
|
|||
Need DOS help
I did not provide a good example in the first post so here's another
that I've tested on both WinXP and WinME ------------------------- @ECHO OFF REM folder Bat C: IF EXIST C:\FSS GOTO :YES :NO ECHO ~ ECHO THERE IS NO FOLDER PAUSE GOTO :END :YES ECHO ~ ECHO THE FOLDER WAS FOUND PAUSE :END ------------------------ Once again, using; WinXP, I get "The Folder was Found" WinME, I get "There is no folder" and, of course there is a c:\fss folder Hope this helps, Fred Fred S ***** wrote: Hi folks, I'm writing a batch file and need to check for the presence of a folder. I find that the "IF EXIST ...." syntax only works for text in WinME. I can use this in WinXP but NOT in ME IF EXIST C:\TEST GOTO END :START RENAME C:\START\SAMPLE.TXT JONES.TXT GOTO DONE :END ERASE C:\TEST\XXXX.TXT YYYY.TXT GOTO DONE ONE EXIT Running this batch file in WinXP works fine but in WinME it does NOT follow the directions. It simply drops to the next line after the IF EXIST statement. Same thing happens if I use IF NOT EXIST - just goes to the nest line. Can someone advise on how to check if a folder is there and how to jump to one or more places in the batch file for other actions? Thanks, Fred |
#3
|
|||
|
|||
Need DOS help
Check your colons and other typos fred.
"Fred S *****" "Fred wrote in message ... I did not provide a good example in the first post so here's another that I've tested on both WinXP and WinME ------------------------- @ECHO OFF REM folder Bat C: IF EXIST C:\FSS GOTO :YES :NO ECHO ~ ECHO THERE IS NO FOLDER PAUSE GOTO :END :YES ECHO ~ ECHO THE FOLDER WAS FOUND PAUSE :END ------------------------ Once again, using; WinXP, I get "The Folder was Found" WinME, I get "There is no folder" and, of course there is a c:\fss folder Hope this helps, Fred Fred S ***** wrote: Hi folks, I'm writing a batch file and need to check for the presence of a folder. I find that the "IF EXIST ...." syntax only works for text in WinME. I can use this in WinXP but NOT in ME IF EXIST C:\TEST GOTO END :START RENAME C:\START\SAMPLE.TXT JONES.TXT GOTO DONE :END ERASE C:\TEST\XXXX.TXT YYYY.TXT GOTO DONE ONE EXIT Running this batch file in WinXP works fine but in WinME it does NOT follow the directions. It simply drops to the next line after the IF EXIST statement. Same thing happens if I use IF NOT EXIST - just goes to the nest line. Can someone advise on how to check if a folder is there and how to jump to one or more places in the batch file for other actions? Thanks, Fred |
#4
|
|||
|
|||
Need DOS help
It's not that simple, shep,
Same thing happens on my WinMe and XP boxes. The syntax is certainly correct, according to the help file in the oldmsdos (v6.22) folder - on the WinMe CD. Other than WinMe's (virtual) DOS is different to Real Mode DOS, so far, I can't think of an explanation. Mart "shep" wrote in message ... Check your colons and other typos fred. "Fred S *****" "Fred wrote in message ... I did not provide a good example in the first post so here's another that I've tested on both WinXP and WinME ------------------------- @ECHO OFF REM folder Bat C: IF EXIST C:\FSS GOTO :YES :NO ECHO ~ ECHO THERE IS NO FOLDER PAUSE GOTO :END :YES ECHO ~ ECHO THE FOLDER WAS FOUND PAUSE :END ------------------------ Once again, using; WinXP, I get "The Folder was Found" WinME, I get "There is no folder" and, of course there is a c:\fss folder Hope this helps, Fred Fred S ***** wrote: Hi folks, I'm writing a batch file and need to check for the presence of a folder. I find that the "IF EXIST ...." syntax only works for text in WinME. I can use this in WinXP but NOT in ME IF EXIST C:\TEST GOTO END :START RENAME C:\START\SAMPLE.TXT JONES.TXT GOTO DONE :END ERASE C:\TEST\XXXX.TXT YYYY.TXT GOTO DONE ONE EXIT Running this batch file in WinXP works fine but in WinME it does NOT follow the directions. It simply drops to the next line after the IF EXIST statement. Same thing happens if I use IF NOT EXIST - just goes to the nest line. Can someone advise on how to check if a folder is there and how to jump to one or more places in the batch file for other actions? Thanks, Fred |
#5
|
|||
|
|||
Need DOS help
"Fred S *****" "Fred wrote in message
... I did not provide a good example in the first post so here's another that I've tested on both WinXP and WinME ------------------------- @ECHO OFF REM folder Bat C: IF EXIST C:\FSS GOTO :YES :NO ECHO ~ ECHO THERE IS NO FOLDER PAUSE GOTO :END :YES ECHO ~ ECHO THE FOLDER WAS FOUND PAUSE :END ------------------------ Once again, using; WinXP, I get "The Folder was Found" WinME, I get "There is no folder" and, of course there is a c:\fss folder Hope this helps, Fred Fred S ***** wrote: Hi folks, I'm writing a batch file and need to check for the presence of a folder. I find that the "IF EXIST ...." syntax only works for text in WinME. I can use this in WinXP but NOT in ME IF EXIST C:\TEST GOTO END :START RENAME C:\START\SAMPLE.TXT JONES.TXT GOTO DONE :END ERASE C:\TEST\XXXX.TXT YYYY.TXT GOTO DONE ONE EXIT Running this batch file in WinXP works fine but in WinME it does NOT follow the directions. It simply drops to the next line after the IF EXIST statement. Same thing happens if I use IF NOT EXIST - just goes to the nest line. Can someone advise on how to check if a folder is there and how to jump to one or more places in the batch file for other actions? Thanks, Fred Try using the NUL filename, as show in the following example; ------------------------- @ECHO OFF REM folder Bat C: IF EXIST C:\FSS\NUL GOTO :YES :NO ECHO ~ ECHO THERE IS NO FOLDER PAUSE GOTO :END :YES ECHO ~ ECHO THE FOLDER WAS FOUND PAUSE :END ------------------------ |
#6
|
|||
|
|||
Need DOS help
Neat one Tim!
Perhaps if I'd spent a little more time reading the help page properly, I would have sussed it g Odd though, that '\NUL' isn't needed for XP Mart "Tim Jackson" wrote in message ... "Fred S *****" "Fred wrote in message ... I did not provide a good example in the first post so here's another that I've tested on both WinXP and WinME ------------------------- @ECHO OFF REM folder Bat C: IF EXIST C:\FSS GOTO :YES :NO ECHO ~ ECHO THERE IS NO FOLDER PAUSE GOTO :END :YES ECHO ~ ECHO THE FOLDER WAS FOUND PAUSE :END ------------------------ Once again, using; WinXP, I get "The Folder was Found" WinME, I get "There is no folder" and, of course there is a c:\fss folder Hope this helps, Fred Fred S ***** wrote: Hi folks, I'm writing a batch file and need to check for the presence of a folder. I find that the "IF EXIST ...." syntax only works for text in WinME. I can use this in WinXP but NOT in ME IF EXIST C:\TEST GOTO END :START RENAME C:\START\SAMPLE.TXT JONES.TXT GOTO DONE :END ERASE C:\TEST\XXXX.TXT YYYY.TXT GOTO DONE ONE EXIT Running this batch file in WinXP works fine but in WinME it does NOT follow the directions. It simply drops to the next line after the IF EXIST statement. Same thing happens if I use IF NOT EXIST - just goes to the nest line. Can someone advise on how to check if a folder is there and how to jump to one or more places in the batch file for other actions? Thanks, Fred Try using the NUL filename, as show in the following example; ------------------------- @ECHO OFF REM folder Bat C: IF EXIST C:\FSS\NUL GOTO :YES :NO ECHO ~ ECHO THERE IS NO FOLDER PAUSE GOTO :END :YES ECHO ~ ECHO THE FOLDER WAS FOUND PAUSE :END ------------------------ |
#7
|
|||
|
|||
Need DOS help
Tim Jackson wrote: "Fred S *****" "Fred wrote in message ... I did not provide a good example in the first post so here's another that I've tested on both WinXP and WinME ------------------------- @ECHO OFF REM folder Bat C: IF EXIST C:\FSS GOTO :YES :NO ECHO ~ ECHO THERE IS NO FOLDER PAUSE GOTO :END :YES ECHO ~ ECHO THE FOLDER WAS FOUND PAUSE :END ------------------------ Once again, using; WinXP, I get "The Folder was Found" WinME, I get "There is no folder" and, of course there is a c:\fss folder Hope this helps, Fred Fred S ***** wrote: Hi folks, I'm writing a batch file and need to check for the presence of a folder. I find that the "IF EXIST ...." syntax only works for text in WinME. I can use this in WinXP but NOT in ME IF EXIST C:\TEST GOTO END :START RENAME C:\START\SAMPLE.TXT JONES.TXT GOTO DONE :END ERASE C:\TEST\XXXX.TXT YYYY.TXT GOTO DONE ONE EXIT Running this batch file in WinXP works fine but in WinME it does NOT follow the directions. It simply drops to the next line after the IF EXIST statement. Same thing happens if I use IF NOT EXIST - just goes to the nest line. Can someone advise on how to check if a folder is there and how to jump to one or more places in the batch file for other actions? Thanks, Fred Try using the NUL filename, as show in the following example; ------------------------- @ECHO OFF REM folder Bat C: IF EXIST C:\FSS\NUL GOTO :YES :NO ECHO ~ ECHO THERE IS NO FOLDER PAUSE GOTO :END :YES ECHO ~ ECHO THE FOLDER WAS FOUND PAUSE :END ------------------------ Hi Tim, Thanks for that, I'll give it a try. Fred |
#8
|
|||
|
|||
Need DOS help
Check out Prof Timo Salmi's collections of examples:
http://garbo.uwasa.fi/pc/ts.html There's one for batch in DOS (tsbat) and one for NT (tscmd). You are likely to find at least some of it indispensible. Shane Fred S *****" "Fred S wrote: Hi folks, I'm writing a batch file and need to check for the presence of a folder. I find that the "IF EXIST ...." syntax only works for text in WinME. I can use this in WinXP but NOT in ME IF EXIST C:\TEST GOTO END START RENAME C:\START\SAMPLE.TXT JONES.TXT GOTO DONE END ERASE C:\TEST\XXXX.TXT YYYY.TXT GOTO DONE DONE EXIT Running this batch file in WinXP works fine but in WinME it does NOT follow the directions. It simply drops to the next line after the IF EXIST statement. Same thing happens if I use IF NOT EXIST - just goes to the nest line. Can someone advise on how to check if a folder is there and how to jump to one or more places in the batch file for other actions? Thanks, Fred |
Thread Tools | |
Display Modes | |
|
|