Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Batch file - output " ...done! " after an operation?  (Read 5478 times)

0 Members and 1 Guest are viewing this topic.

S3NTYN3L

    Topic Starter


    Rookie

    • Yes
  • Experience: Familiar
  • OS: Windows 7
Batch file - output " ...done! " after an operation?
« on: April 09, 2012, 06:35:40 AM »
Perhaps I'm just boneheaded and not seeing the obvious, but can someone please tell me how I'd get my batch to append " done! ", or similar, after an operation?

I know I can do this with clever use of the ECHO command, as below, but I'm wondering if there's an easier way because using the ECHO method gets tedious when several commands are desired on screen. :-\

A simple example of what I'm using now:

Code: [Select]
@ECHO OFF

CLS
ECHO Running command 1...
Put command 1 here

CLS
ECHO Running command 1... done!

CLS
ECHO Running command 1... done!
ECHO Running command 2...
Put command 2 here

CLS
ECHO Running command 1... done!
ECHO Running command 2... done!
ECHO Running command 3...
Put command 3 here

CLS
ECHO Running command 1... done!
ECHO Running command 2... done!
ECHO Running command 3... done!

ECHO All done, exiting...

EXIT


The output, (with command 3 not yet complete), would look like this:

Code: [Select]
Running command 1... done!
Running command 2... done!
Running command 3...

Salmon Trout

  • Guest
Re: Batch file - output " ...done! " after an operation?
« Reply #1 on: April 09, 2012, 07:04:07 AM »
You are looking for a way of appending something to the same line?

So you have

Running command 1... (then you run command1) and then you see done! at the end of the same line - is that what you want?

Here is a trick using set /p to show text without a newline:


@echo off
0>nul set /p="Running command1... "
ping www.google.com > nul
echo done!






S3NTYN3L

    Topic Starter


    Rookie

    • Yes
  • Experience: Familiar
  • OS: Windows 7
Re: Batch file - output " ...done! " after an operation?
« Reply #2 on: April 09, 2012, 07:10:28 AM »
You are looking for a way of appending something to the same line?


Yea, that's exactly what I want, thanks!


So, If I'm thinking this through correctly, I'd use your template above and simply replace your ping command for mine, yes?

Can I assume that this method supports multiple commands?

For example:

Code: [Select]

@echo off
0>nul set /p="Running CommandSet1... "
ping www.google.com > nul
ping www.sony.com > nul
ping www.yahoo.com >nul
echo done!


Salmon Trout

  • Guest
Re: Batch file - output " ...done! " after an operation?
« Reply #3 on: April 09, 2012, 07:16:19 AM »
Since experimentation is the key to learning, why don't you try that and see if it works?

S3NTYN3L

    Topic Starter


    Rookie

    • Yes
  • Experience: Familiar
  • OS: Windows 7
Re: Batch file - output " ...done! " after an operation?
« Reply #4 on: April 09, 2012, 07:25:35 AM »
Just got done doing so and answered my own questions, thank you!

Salmon Trout

  • Guest
Re: Batch file - output " ...done! " after an operation?
« Reply #5 on: April 09, 2012, 08:21:46 AM »
Another thing to try:


@echo off
0>nul set /p="Running CommandSet1"
ping www.google.com > nul
0>nul set /p="."
ping www.sony.com > nul
0>nul set /p="."
ping www.yahoo.com >nul
0>nul set /p="."
ping www.yahoo.com >nul
0>nul set /p="."
ping www.yahoo.com >nul
0>nul set /p="."
ping www.yahoo.com >nul
0>nul set /p="."
ping www.yahoo.com >nul
0>nul set /p=". "
echo done!


S3NTYN3L

    Topic Starter


    Rookie

    • Yes
  • Experience: Familiar
  • OS: Windows 7
Re: Batch file - output " ...done! " after an operation?
« Reply #6 on: April 10, 2012, 12:13:13 PM »
Perfect, thanks! ;)