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

Is there an opposite to '@' ?

9 views
Skip to first unread message

R.Wieser

unread,
Apr 30, 2021, 4:30:27 AM4/30/21
to
Hello all,

Yesterday I got caught out by a batchfile (which I wrote myself :-) )
changing the current directory - I thought I was still in the old one ...

I decided that I would need to make that 'cd' (its output) visible (I've
used "@echo off" at the top). I can ofcourse do that in a number of ways,
but the cleanest way would be if I could allow the 'cd' command to display
its output.

The question is : is there a prefix that will disable the "echo off" for
that one line / command ?

Regards,
Rudy Wieser


R.Wieser

unread,
Apr 30, 2021, 6:53:58 AM4/30/21
to
John,

>> The question is : is there a prefix that will disable the "echo off"
>> for that one line / command ?
>
> Not that I know of;

I could not think of one either.

> as you say there's ways around it; insert a bare line "CD" after
> the "CD \mydir" is the simplest I can think of.

Ehrmm ... It looks like I got caught out more than once :

I somehow was able to bullshit myself and not recognise it : The '@' prefix
will suppress displaying the batch line itself, but certainly not its
output. And that ofcourse means that, as you said, a 'cd' on a line on its
own, prefixed or not, will display the current directory.

Also, when the batchfile ends the/my $P$G prompt will display the current
directory when asking for input.
IOW, I was told, but I simply did not register it. :-(

> A more tedious solution is to [snip]

I also thought of those, inclusive, after having posted my question, the ">
CON" method. It was during testing of it that I recognised what a load of
crap I had been posting (not the question itself, but that I needed it). :-|

Thanks for the response.

Regards,
Rudy Wieser


Thomas Langer

unread,
Apr 30, 2021, 6:54:14 AM4/30/21
to
There is an environment variable %cd% that is automatically getenerated
by os.

try:
echo %cd%

hth
Thomas Langer

Grant Taylor

unread,
Apr 30, 2021, 12:06:12 PM4/30/21
to
On 4/30/21 2:30 AM, R.Wieser wrote:
> Hello all,

Hi,

> Yesterday I got caught out by a batchfile (which I wrote myself :-)
> ) changing the current directory - I thought I was still in the old
> one ...

Oops

> I decided that I would need to make that 'cd' (its output) visible
> (I've used "@echo off" at the top). I can ofcourse do that in a
> number of ways, but the cleanest way would be if I could allow the
> 'cd' command to display its output.

It's been a while since I've done much in DOS, but I don't think that
'@echo off' changes the /output/ generated by commands.

More specifically, '@echo off' is intended to not show the batch file
/input/ while executing. Read: hide the command to be executed, but not
touch the command's output.

> The question is : is there a prefix that will disable the "echo off"
> for that one line / command ?

Yes and no.

'echo on'

E.g.

@echo off
dir
copy foo bat
echo on
cd \test
@echo off
dir

Remember, the '@' prefix is a per command 'echo off'. Meaning that the
'@' and 'echo off' are two completely independent things.

So ... you can turn echo back on for the cd command and then
subsequently turn it off for the rest of the batch file.

Another trick that I use for short batch files (9 or fewer lines) is:

@dir
@copy foo bat
@echo on
cd \test
@dir

Simply use '@' before each command that you want to not see.

The reason I say 'short' batch files is that '@echo off' is 9 bytes.
Meaning that the above batch file uses fewer bytes by prepending '@' to
thel ines than including an additional line that is '@ech off'. You can
do it for as long a batch file as you want. It just becomes a lot less
efficient and more annoying to add '@' to 30 lines instead of a single
'@echo off'. YMMV.



--
Grant. . . .
unix || die

R.Wieser

unread,
Apr 30, 2021, 12:47:20 PM4/30/21
to
Grant,

>> Yesterday I got caught out by a batchfile (which I wrote myself :-) )
>> changing the current directory - I thought I was still in the old one ...
>
> Oops

Yup. Luckily nothing bad happened. Just had to figure out why I could not
find my files.

> More specifically, '@echo off' is intended to not show the batch file
> /input/ while executing. Read: hide the command to be executed, but not
> touch the command's output.

Yup. But alas, I only realized my blunder /after/ having posted my question
...

In short : the problem I thought I had doesn't exist. It was just me having
some kind of brain-freeze or something. :-|

Regards,
Rudy Wieser


Grant Taylor

unread,
Apr 30, 2021, 7:25:21 PM4/30/21
to
On 4/30/21 10:47 AM, R.Wieser wrote:
> In short : the problem I thought I had doesn't exist. It was just
> me having some kind of brain-freeze or something. :-|

Don't let anybody fool you. That happens. Try to learn from it and
move on.

R.Wieser

unread,
May 1, 2021, 4:16:11 AM5/1/21
to
Grant,

> Don't let anybody fool you. That happens.

Yup. As shown by yours truly.

> Try to learn from it and move on.

It has taught me that I, the great-and-mighty Rudy Wieser, am not above
making mistakes. :-)

Than again, I can't remember the last time I thought I was ...

Regards,
Rudy Wieser


Fin Tres Nueve Dos

unread,
May 2, 2021, 1:42:36 AM5/2/21
to
The opposite to '@' is ... not to use '@'.

Instead of:

@ECHO OFF
COMMAND 1...
COMMAND 2...
:: Opposite to @ ???? COMMAND 3...
COMMAND 4...
COMMAND 5...
...

You can write:

@COMMAND 1...
@COMMAND 2...
COMMAND 3...
@COMMAND 4...
@COMMAND 5...

R.Wieser

unread,
May 2, 2021, 2:43:19 AM5/2/21
to
Fin,

> The opposite to '@' is ... not to use '@'.

And with "not to use '@' " you actually mean "use it pretty-much
everywhere". :-D

But yes, that was, in my initial message, one of the ways I knew how to do
it. I was hoping for a cleaner, simpler way though.

Regards,
Rudy Wieser


0 new messages