Computing.Net > Forums > Disk Operating System > Sudirectory or file already exists

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Sudirectory or file already exists

Reply to Message Icon

Name: jamesmp3
Date: February 4, 2005 at 23:34:46 Pacific
OS: XP
CPU/Ram: P4 1GB
Comment:

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




Sponsored Link
Ads by Google

Response Number 1
Name: Mike Newcomb
Date: February 5, 2005 at 01:10:35 Pacific
Reply:

You appear to be MD GASBOYLOG while on C:root, hence the error message as it already exists.

Perhaps this should be:-
MD A:GASBOYLOG

or

A:
MD GASBOYLOG
C:

Good luck - Keep us posted.


0

Response Number 2
Name: jamesmp3
Date: February 5, 2005 at 09:22:22 Pacific
Reply:

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?


0

Response Number 3
Name: Nigel Spike
Date: February 5, 2005 at 11:29:09 Pacific
Reply:

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


Nigel


0

Response Number 4
Name: IVO
Date: February 5, 2005 at 12:58:24 Pacific
Reply:

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.txt

That works under Win 2K/XP only so please, DOS boys, don't hate me.


0

Response Number 5
Name: Nigel Spike
Date: February 5, 2005 at 15:09:56 Pacific
Reply:

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

Nigel


0

Related Posts

See More



Response Number 6
Name: Mechanix2Go
Date: February 6, 2005 at 18:22:42 Pacific
Reply:

jamesmp3

if not exist c:\gasboylog\nul md c:\gasboylog

M2


0

Response Number 7
Name: jamesmp3
Date: February 6, 2005 at 18:41:24 Pacific
Reply:

Can Nigel and or IVO insert the code in my bat file? I have tried and failed.
Thanks

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\
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


0

Response Number 8
Name: IVO
Date: February 7, 2005 at 02:49:00 Pacific
Reply:

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=



0

Response Number 9
Name: Nigel Spike
Date: February 7, 2005 at 10:15:08 Pacific
Reply:

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


0

Response Number 10
Name: Rick McNabb
Date: February 7, 2005 at 16:52:42 Pacific
Reply:

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.


0

Response Number 11
Name: Nigel Spike
Date: February 8, 2005 at 09:32:22 Pacific
Reply:

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


0

Response Number 12
Name: rogerashley
Date: February 8, 2005 at 13:12:41 Pacific
Reply:

It could be you are discussing MSDOS
commands in a NT COMMAND PROMPT
environment!



0

Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

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


Go to Disk Operating System Forum Home


Sponsored links

Ads by Google


Results for: Sudirectory or file already exists

Directory already exists www.computing.net/answers/dos/directory-already-exists/5529.html

Is there any (free) program that can build COM or EXE'S from BAT files and if so,where can I find such a program? www.computing.net/answers/dos/is-there-any-free-program-that-can-build-com-or-exes-from-bat-files-and-if-sowhere-can-i-find-such-a-program/3814.html

MSDOS responds BAD COMMAND OR FILE www.computing.net/answers/dos/msdos-responds-bad-command-or-file/15910.html