Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Echo blank line from batch file

2 views
Skip to first unread message

eso...@cerner.com

unread,
Dec 26, 2005, 4:44:26 PM12/26/05
to
I have tried using echo. (echo followed by period) to create a blank
line. I get the error:
'echo.' is not recognized as an internal or external command,
operable program or batch file.

Any ideas/suggestions would be helpful.
Thanks in advance.

Here is the bat file:
@echo off
REM HNACP00012012
if "%1"=="" goto usage
if "%2"=="" goto usage
if "%3"=="" goto usage
for /f "skip=1 delims=" %%a in ('DIR "%~1\%~2*.%3" /A-D /O-D /B /TW')
do ECHO %1\%%a
for /f "skip=1 delims=" %%a in ('DIR "%~1\%~2*.%3" /A-D /O-D /B /TW')
do del "%1\%%a"
goto xit
:usage
echo Usage: %0 directory fileprefix fileextension
echo.
echo This will change to the specified directory.
echo It will delete all files named fileprefix*.fileextension except
the one last written to.
echo.
echo Example: %0 c:\INFOSTAT\temp HISRpt txt
echo.
echo This will delete all files named HISRpt*.txt in the
c:\INFOSTAT\temp directory
echo except the one with the latest write date.
:xit

Here is what I get when I issue the command: CleanAllButLast

Usage: CleanAllButLast.bat directory fileprefix fileextension
'echo.' is not recognized as an internal or external command,
operable program or batch file.
This will change to the specified directory.
It will delete all files named fileprefix*.fileextension except the one
last wri
tten to.
'echo.' is not recognized as an internal or external command,
operable program or batch file.
Example: CleanAllButLast.bat c:\INFOSTAT\temp HISRpt txt
'echo.' is not recognized as an internal or external command,
operable program or batch file.
This will delete all files named HISRpt*.txt in the c:\INFOSTAT\temp
directory
except the one with the latest write date.

Todd Vargo

unread,
Dec 27, 2005, 1:29:54 AM12/27/05
to

<eso...@cerner.com> wrote in message
news:1135633466.4...@f14g2000cwb.googlegroups.com...

> I have tried using echo. (echo followed by period) to create a blank
> line. I get the error:
> 'echo.' is not recognized as an internal or external command,
> operable program or batch file.
>
> Any ideas/suggestions would be helpful.
> Thanks in advance.
>
> Here is the bat file:
> @echo off
> REM HNACP00012012
> if "%1"=="" goto usage
> if "%2"=="" goto usage
> if "%3"=="" goto usage

Since you insist on forcing 3 seperate arguments (ill advised), you may well
be advised you only need check if the third (last required) was given. The
first two argument checks are redundant. Also, if any arguments include
spaces, then you are in effect doubling the quoting. To prevent this from
occuring use the %~ syntax.

if "%~3"=="" goto usage


> for /f "skip=1 delims=" %%a in ('DIR "%~1\%~2*.%3" /A-D /O-D /B /TW')
> do ECHO %1\%%a

DIR's /TW seems to be the default behaivor, but your system may vary. The
following single argument batch should do what you want to acomplish.

@echo off
if [%1]==[] echo Syntax %~n0 [drive:][\path\]filespec.ext&goto :EOF
for /f "skip=1 delims=" %%a in ('DIR %1 /A-D/O-D/B') do del "%~dp1%%a"


> for /f "skip=1 delims=" %%a in ('DIR "%~1\%~2*.%3" /A-D /O-D /B /TW')
> do del "%1\%%a"
> goto xit
> :usage
> echo Usage: %0 directory fileprefix fileextension
> echo.

snip...


> Here is what I get when I issue the command: CleanAllButLast
>
> Usage: CleanAllButLast.bat directory fileprefix fileextension
> 'echo.' is not recognized as an internal or external command,
> operable program or batch file.

snip...

What program are you using to save your batch file?

BTW, for anyone not aware, there are groups specifically for NT/2K/XP
related batch discussions. Here are 2 such groups...
<news:alt.msdos.batch.nt>
<news://news.microsoft.com/microsoft.public.win2000.cmdprompt.admin>

And if you don't have access to those, try using...
<http://groups.google.com/groups?as_ugroup=alt.msdos.batch.nt>

--
Todd Vargo (double "L" to reply by email)

Richard Bonner

unread,
Dec 27, 2005, 1:28:35 PM12/27/05
to
eso...@cerner.com wrote:
> I have tried using echo. (echo followed by period) to create a blank
> line. I get the error:
> 'echo.' is not recognized as an internal or external command,
> operable program or batch file.

*** There are other characters which can be used, but I can't remember
them. One method which I do remember is to use TYPE to "display" a text
file that contains a carriage return.

Richard Bonner
http://www.chebucto.ca/~ak621/DOS/

tlav...@hotmail.com

unread,
Dec 27, 2005, 1:39:01 PM12/27/05
to
That is extremely unusual behavior. It would appear to me that your OS
is trying to find a program named ECHO, which it should not do. Try
substituting another punctuation mark for the period, like a comma or
and equal sign to see if that will get you out of this situation. All
are valid in all versions of Windows abd even in 'real DOS, AFAIK.

Tom Lavedas
============
http://my.fcc.net/~tglbatch (new URL - old content)

eso...@cerner.com wrote:
> I have tried using echo. (echo followed by period) to create a blank
> line. I get the error:
> 'echo.' is not recognized as an internal or external command,
> operable program or batch file.
>
> Any ideas/suggestions would be helpful.
> Thanks in advance.

{snip}

Timo Salmi

unread,
Dec 27, 2005, 3:05:23 PM12/27/05
to
eso...@cerner.com wrote in alt.msdos.batch

> I have tried using echo. (echo followed by period) to create a blank
> line. I get the error:
> 'echo.' is not recognized as an internal or external command,
> operable program or batch file.

It is obvious from the rest of you code that you are not using
MS-DOS+Win../95/98/Me but NT/2000/XP. I prefer to post my own
NT/2000/XP answers to news:alt.msdos.batch.nt so for my own posting
thread I have included and redirected.

Your problem is a common one
89} All of a sudden "echo." doesn't work any more. What's wrong?
144994 Dec 7 2005 ftp://garbo.uwasa.fi/pc/link/tscmd.zip
tscmd.zip Useful NT/2000/XP script tricks and tips, T.Salmi

All the best, Timo

--
Prof. Timo Salmi ftp & http://garbo.uwasa.fi/ archives 193.166.120.5
Department of Accounting and Business Finance ; University of Vaasa
mailto:t...@uwasa.fi <http://www.uwasa.fi/~ts/> ; FIN-65101, Finland
Useful batch files and tricks ftp://garbo.uwasa.fi/pc/link/tsbat.zip

Message has been deleted

Timo Salmi

unread,
Dec 27, 2005, 3:07:41 PM12/27/05
to
eso...@cerner.com wrote:
> I have tried using echo. (echo followed by period) to create a blank
> line. I get the error:
> 'echo.' is not recognized as an internal or external command,
> operable program or batch file.

It is obvious from the omitted rest of your code that you are not

Richard Bonner

unread,
Dec 27, 2005, 6:07:01 PM12/27/05
to
> eso...@cerner.com wrote:
> > I have tried using echo. (echo followed by period) to create a blank
> > line. I get the error: 'echo.' is not recognized as an internal or
> > external command, operable program or batch file.

tlav...@hotmail.com wrote:
> Try
> substituting another punctuation mark for the period, like a comma or
> and equal sign to see if that will get you out of this situation. All
> are valid in all versions of Windows abd even in 'real DOS, AFAIK.

> Tom Lavedas

*** Not the `=' sign. It gives the status of "echo".

Richard Bonner
http://www.chebucto.ca/~ak621/DOS/

PS: Please don't top post.

R.

Todd Vargo

unread,
Dec 27, 2005, 11:35:43 PM12/27/05
to

"Richard Bonner" <ak...@chebucto.ns.ca> wrote in message
news:doshel$oo7$2...@News.Dal.Ca...

> > eso...@cerner.com wrote:
> > > I have tried using echo. (echo followed by period) to create a blank
> > > line. I get the error: 'echo.' is not recognized as an internal or
> > > external command, operable program or batch file.
>
> tlav...@hotmail.com wrote:
> > Try
> > substituting another punctuation mark for the period, like a comma or
> > and equal sign to see if that will get you out of this situation. All
> > are valid in all versions of Windows abd even in 'real DOS, AFAIK.
>
> > Tom Lavedas
>
> *** Not the `=' sign. It gives the status of "echo".

In what OS and version does the equal sign give ECHO status?

Richard Bonner

unread,
Dec 28, 2005, 7:54:38 AM12/28/05
to
Todd Vargo wrote:

> "Richard Bonner" <ak...@chebucto.ns.ca> wrote:
(Re:( Echo=")


> > *** Not the `=' sign. It gives the status of "echo".

> In what OS and version does the equal sign give ECHO status?
> --
> Todd Vargo

*** All stand-alone MS versions. I also think PC-DOS exhibits this, but
can't remember. I haven't used PC-DOS in many years. Does anyone here have
a PC-DOS setup who could test this?

DR-DOS will give a blank line with most of the common punctuation
characters, and will also do so with the `=' sign.

Richard Bonner
http://www.chebucto.ca/~ak621/DOS/

eso...@cerner.com

unread,
Dec 28, 2005, 10:39:08 AM12/28/05
to
Thanks to all who helped. Sorry I posted in the wrong forum but did
not know about alt.msdos.batch.nt. I will post there in the future if
I have other questions relating to batch files.

Looking at a posting in alt.msdos.batch.nt, it appears the problem is I
had a file called "echo" (don't know how it got there) in the same
directory as my bat file. Deleting the file and using echo. (echo
followed by period) then worked as expected.

BTW - using echo, (echo followed by comma) or echo= (echo followed by
equal sign) did work even if I had a file called "echo" in the
directory.

eso...@cerner.com

unread,
Dec 28, 2005, 11:01:05 AM12/28/05
to
I have adopted your suggestion for testing just the 3rd parameter. I
need 3 parameters because this is a general purpose script and I don't
know what directory or the files within it (including their extensions)
are to be deleted. Not all the files in the directory are to be
deleted. Just those which are specified and to retain the latest
written one of that name prefix and extension.
I am using Wordpad to edit and save my file.

billious

unread,
Dec 28, 2005, 12:01:12 PM12/28/05
to

<eso...@cerner.com> wrote in message
news:1135783200.2...@z14g2000cwz.googlegroups.com...

Now which file might that be?

If you're referring to your BATCH file, then it might be an idea to use
Notepad or EDIT (from the prompt) for this purpose. Wordpad tends to save
formatting information that makes CMD.EXE very ill indeed.

HTH

...Bill

Todd Vargo

unread,
Dec 28, 2005, 4:42:37 PM12/28/05
to

<eso...@cerner.com> wrote in message
news:1135783200.2...@z14g2000cwz.googlegroups.com...

I understand you want to do things your own way but have you tried using the
modified foxidrive code as I posted? There is no harm in taking a look at
other methods. You may change your mind after you compare it's usage.

By using your example arguments as a single parameter (as shown below) the
code I posted works in Windows 2K/XP, and IMO, typing this way is more
natural and meaningful than using multiple parameters with the wildcard
excluded.

CleanAllButLast c:\INFOSTAT\temp\HISRpt*.txt


> I am using Wordpad to edit and save my file.

It seems the file named ECHO was the culprit but I agree with billious on
preference to using Notepad over Wordpad to avoid accidental formatted
saves. Good luck in your batch expeditions.

eso...@cerner.com

unread,
Dec 29, 2005, 12:16:57 PM12/29/05
to
Sorry. I didn't understand what you were originally suggesting. The
only reason I was making multiple parameters is that this is being
called from another bat file. I think I can modify the calling bat
file to send a single parameter created from the pieces it has.
I have the Usage giving more information than just the syntax because
this is used by clients who may not be all that technical. If it were
just for programmers, I would use the Usage you supplied.
Now that I know there's a difference, I will use Notepad when I edit
bat files.

Thanks for all the help and suggestions.

Richard Bonner

unread,
Dec 29, 2005, 1:29:05 PM12/29/05
to
eso...@cerner.com wrote:
> Looking at a posting in alt.msdos.batch.nt, it appears the problem is I
> had a file called "echo" (don't know how it got there) in the same
> directory as my bat file. Deleting the file and using echo. (echo
> followed by period) then worked as expected.

*** I suspect the reason for that was that "ECHO." is a legal file name.
It would be similar to the format of "ECHO.txt" but without the extension.

Richard Bonner
http://www.chebucto.ca/~ak621/DOS/

Richard Bonner

unread,
Dec 29, 2005, 1:33:45 PM12/29/05
to
Todd Vargo wrote:
> I understand you want to do things your own way but have you tried using the
> modified foxidrive code as I posted? There is no harm in taking a look at
> other methods. You may change your mind after you compare it's usage.
> --
> Todd Vargo

*** I heartily endorse this method. There are many solutions for a
given batch file problem, and each that works is just as valid as any
others that work.

Trying various alternate methods is a good learning tool. One may also
find advantages for one method over another.

Richard Bonner
http://www.chebucto.ca/~ak621/DOS/

eso...@cerner.com

unread,
Dec 30, 2005, 10:45:39 AM12/30/05
to
As I said, it wasn't that I wanted to do things my own way. Although I
am familiar with techniques in UNIX, "DOS" batch file writing is a
little confusing and I didn't understand what Todd was suggesting I do
until a later posting. Once I understood what he was suggesting, it
was the obvious right thing to do.
You are right. Having all these postings is a very good way to learn
the intricacies of batch file commands. I always learn something from
everyone's posting, especially the cross discussion between people who
are knowledgeable.

Thanks so much to all of you. I know I would not have had the
efficient (and correct) code and approach without your help.

0 new messages