Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
This is my .bat
CD\
PAUSE
ECHO INSERT DISKETTE INTO 3 1/2 FLOPPY DRIVE A:
PAUSE
ECHO TRANSFERRING DATA TO DISKETTE, PLEASE WAIT.
CD\
CD SWWIN
CD DATA
COPY C:\SWWin\Data\new_plu.asc A:
CD\
MD GASBOYLOG
PAUSE
ECHO %DATE% %TIME% Transfer of new pricing has completed... >> C:\GASBOYLOG\Logfile.txt
ECHO FINISHED WITH TRANSFER, REMOVE DISKETTE.I get this message when I run the .bat. "A subdirectory or file GASBOYLOG already exists". Can an IF [NOT] ELSE be used to not show this message? If so how? Also can a question be asked in the .bat that would ask "Do you want to view the logfile?" if answered N(o) the .bat will close, if Y(es) it will show on the screen the file in this path C:\GASBOYLOG\Logfile.txt? If so how?
Thanks

You appear to be MD GASBOYLOG while on C:root, hence the error message as it already exists.
Perhaps this should be:-
MD A:GASBOYLOGor
A:
MD GASBOYLOG
C:Good luck - Keep us posted.

I want the directory c:\gasboylog to be on the c:\ drive. I just need it to be created if it's not there and to give no error message if it is there.
Hmmmm?

If exist C:\Gasboylog\. goto Err_Msg1
..
..
:Errmsg1
Echo "The Directory already exists"
Goto Exit
..
..
:Exit
Nigel

About the error message as Nigel Spike suggested with a minor variant, i.e.
If exist C:\Gasboylog\Nul GoTo :Err_Msg1
About to display the Logfile
:LOOP
Set /P Query=Do you want to view the logfile? [Y/N]^>
If /I "Query"=="N" GoTo :EXIT
If /I not "Query"=="Y" GoTo :LOOP
More < C:Gasboylog\Logfile.txtThat works under Win 2K/XP only so please, DOS boys, don't hate me.

Since Jamesmp3 asks in the DOS forum but states his OS as XP there can be no harm in giving him some options ;)
Nigel

Can Nigel and or IVO insert the code in my bat file? I have tried and failed.
ThanksECHO Written by James Empey - PETRODATA, Incorporated.
ECHO.
ECHO Visit our wesite at http://www.petrodata-backoffice.com or call (425) 531-1929
FOR %%@ IN (1 2 3) DO ECHO.
CD\
PAUSE
ECHO.
ECHO INSERT DISKETTE INTO 3 1/2 FLOPPY DRIVE A:
PAUSE
ECHO.
ECHO TRANSFERRING DATA TO DISKETTE, PLEASE WAIT.
CD\
CD SWWIN
CD DATA
COPY C:\SWWin\Data\new_plu.asc A:
CD\
MD GASBOYLOG
PAUSE
ECHO.
ECHO %DATE% %TIME% Transfer of new pricing has completed... >> C:\GASBOYLOG\Logfile.txt
ECHO FINISHED WITH TRANSFER, REMOVE DISKETTE.
ECHO.
ECHO.
ECHO PETRODATA, Incorporated.
ECHO "It's all about the margins"...
ECHO.
ECHO.
ECHO I know, I know, press any key to continue . . .
PAUSE > NUL
CLS

below what you want I suppose
Echo Off
ECHO Written by James Empey - PETRODATA, Incorporated.
ECHO.
ECHO Visit our website at http://www.petrodata-backoffice.com or call (425) 531-1929
Echo.
Echo.
Echo Insert Diskette into 3"1/2 FLOPPY DRIVE A: and Press any key when ready...
Pause > Nul
Echo.
Echo TRANSFERRING DATA TO DISKETTE, PLEASE WAIT...
Copy C:\SWWIN\DATA\new_plu.asc A:
If not exist C:\GASBOYLOG\Nul MD C:\GASBOYLOG
Echo %DATE% %TIME% - Transfer of new pricing has completed... >> C:\GASBOYLOG\Logfile.txt
ECHO FINISHED WITH TRANSFER, REMOVE DISKETTE.
ECHO.
ECHO.
:LOOP
Set /P Query=Do you want to view the logfile? [Y/N]^>
If /I "Query"=="N" GoTo :EXIT
If /I not "Query"=="Y" GoTo :LOOP
More < C:\GASBYLOG\logfile.txt
:EXIT
Set Query=

This is the way I would have done it pure DOS way, given I had to use your file and just amend my suggestions above:
ECHO Written by James Empey - PETRODATA, Incorporated.
ECHO.
ECHO Visit our wesite at http://www.petrodata-backoffice.com or call (425) 531-1929
FOR %%@ IN (1 2 3) DO ECHO.
CD\
PAUSE
ECHO.
ECHO INSERT DISKETTE INTO 3 1/2 FLOPPY DRIVE A:
PAUSE
ECHO.
ECHO TRANSFERRING DATA TO DISKETTE, PLEASE WAIT.
CD\
CD SWWIN
CD DATA
COPY C:\SWWin\Data\new_plu.asc A:
CD\
If exist C:\Gasboylog\. goto Err_Msg1
MD GASBOYLOG
PAUSE
ECHO.
ECHO %DATE% %TIME% Transfer of new pricing has completed... >> C:\GASBOYLOG\Logfile.txt
ECHO FINISHED WITH TRANSFER, REMOVE DISKETTE.
ECHO.
ECHO.
ECHO PETRODATA, Incorporated.
ECHO "It's all about the margins"...
ECHO.
ECHO.
ECHO I know, I know, press any key to continue . . .
PAUSE > NUL
Goto Exit
:Errmsg1
Echo "The Directory already exists"
Goto Exit
:Exit
CLS

Not sure what that was all about, but it won't work.(you misspelled err_msg1)
CD\
PAUSE
ECHO INSERT DISKETTE INTO 3 1/2 FLOPPY DRIVE A:
PAUSE
ECHO TRANSFERRING DATA TO DISKETTE, PLEASE WAIT.
CD\
CD SWWIN
CD DATA
COPY C:\SWWin\Data\new_plu.asc A:
CD\
C:
IF EXIST \GASBOYLOG GOTO MARK
MD \GASBOYLOG
:MARK
A:
PAUSE
ECHO %DATE% %TIME% Transfer of new pricing has completed... >> C:\GASBOYLOG\Logfile.txt
ECHO FINISHED WITH TRANSFER, REMOVE DISKETTE.

Rick
I tried to help him resolve the problem with checking if a directory existed, not analyse or write the file for him.A smaller anaylyse would show that there's no reason to make the source directory current, since the full path is given in the copy command.
Nigel

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |