Stop Command Prompt Empty Line

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Message
Author
flywire
Posts: 17
Joined: 14 Feb 2018 03:10

Stop Command Prompt Empty Line

#1 Post by flywire » 02 Jun 2018 05:41

I process thousands of files in a batch file with prog.exe (which I didn't write) and redirect output from the batch file to a log file. Each time the program is called the command processor prints a blank line to the shell.

I found https://superuser.com/a/97308/514126
> set /p x=foo<nul
foo
> _
When I use it it just prints the program name 'prog' rather than running the program.

How can I suppress the blank lines in the shell?

MarioZac
Posts: 38
Joined: 16 May 2018 00:12

Re: Stop Command Prompt Empty Line

#2 Post by MarioZac » 02 Jun 2018 09:56

Can you reveal just a little more of your actual code? :mrgreen:

flywire
Posts: 17
Joined: 14 Feb 2018 03:10

Re: Stop Command Prompt Empty Line

#3 Post by flywire » 02 Jun 2018 10:40

flywire wrote:
15 Feb 2018 04:46
...

Code: Select all

@echo off 
@echo off 
:: Usage: NestBat [File (without extension) [File (without extension)]] > Batling.bat 
:: 
:: Ver 15/02/2018 (CC BY-SA 4.0) 
:: 
echo Generating ...
:: 
For %%f in (%1*.dat) do ( 
  echo ::
  echo ::*** %%f 
  echo copy %%f DAT 
  echo copy %%f.dta DTA 
  echo copy %%f.dtt DTT 
  echo :: 
::   
  For %%g in (%2*.per) do ( 
    echo ::** %%g 
    echo copy %%g.per PER 
    echo Program 
    echo copy OUT %%f%%g.out 
    echo :: 
  ) 
  echo :: 
) 
echo done. 
:End 
Run Batling.bat as: Batling >Batling.log
I use 'Prog.exe' not 'echo Program'. I get thousands of blank lines written to the shell so the user just sees a blank screen.
Last edited by flywire on 02 Jun 2018 18:05, edited 1 time in total.

pieh-ejdsch
Posts: 239
Joined: 04 Mar 2014 11:14
Location: germany

Re: Stop Command Prompt Empty Line

#4 Post by pieh-ejdsch » 02 Jun 2018 12:05

Hello,
This prog.exe will print all these empty lines to your command line. It means the standard output isn't into handle1. Test the handle number for this output.

Code: Select all

Prog.exe 2>nul
Prog.exe 3>nul
...
Prog.exe 9>nul
Or prog.exe to device CON still writes.
Idon't now how to realize this

Code: Select all

con>nul ( prog.exe )
Phil

flywire
Posts: 17
Joined: 14 Feb 2018 03:10

Re: Stop Command Prompt Empty Line

#5 Post by flywire » 02 Jun 2018 18:00

pieh-ejdsch wrote:
02 Jun 2018 12:05
This prog.exe will print all these empty lines to your command line. It means the standard output isn't into handle1.
No, I think you are wrong. It is a standard exe like any other program. The line comes from the command processor in the shell not the exe. [edit: Tests show the line does come from the program.]

Code: Select all

>prog >nul

>_

Code: Select all

>prog
[program output]

>_

Code: Select all

>con>nul (prog.exe)
' ' is not recognized as an internal or external command,
operable program or batch file.
Last edited by flywire on 04 Jun 2018 16:08, edited 1 time in total.

sst
Posts: 93
Joined: 12 Apr 2018 23:45

Re: Stop Command Prompt Empty Line

#6 Post by sst » 03 Jun 2018 02:09

The more I look at this topic the more it becomes clear to me that it is an instance of XY Problem. Maybe even a nested one.

flywire
Posts: 17
Joined: 14 Feb 2018 03:10

Re: Stop Command Prompt Empty Line

#7 Post by flywire » 03 Jun 2018 02:58

sst wrote:
03 Jun 2018 02:09
XY Problem
How so?

* Batch file used for months supplied, original source even generates sample data
* Program is the same as most other line based executables - windows prompt issues a blank line

pieh-ejdsch
Posts: 239
Joined: 04 Mar 2014 11:14
Location: germany

Re: Stop Command Prompt Empty Line

#8 Post by pieh-ejdsch » 03 Jun 2018 06:01

XY in questions often is a great problem.
BTW if the echo is on- the CLI will print this empty line.

Code: Select all

Set prompt=$g$s
Prog.exe
Echo off
Prog.exe
Your batfile is with echo off. The output into redirected file doesn't have empty lines.
Your example shows an output on the command line with the echo on.

ultimately, for some reason, this program echoes on the command line during output.

Compo
Posts: 599
Joined: 21 Mar 2014 08:50

Re: Stop Command Prompt Empty Line

#9 Post by Compo » 03 Jun 2018 06:03

flywire wrote:
03 Jun 2018 02:58
sst wrote:
03 Jun 2018 02:09
XY Problem
How so?
I'd define an XY problem as a communication problem in which the cause is masked because the person asking for help has presented incomplete information.

There's absolutely no need to hide the actual name and/or version of the executable you are having difficulty with, it most certainly isn't named prog.exe.

Additionally, other than possibly masking/replacing a few specific characters of your actual output, there's no reason not to provide us with enough of the actual output you are having difficulty with, for us to attempt to diagnose the issue.

How do you expect us to help with the output you haven't provided from a program you are keeping a secret?

penpen
Expert
Posts: 2009
Joined: 23 Jun 2013 06:15
Location: Germany

Re: Stop Command Prompt Empty Line

#10 Post by penpen » 03 Jun 2018 06:14

flywire wrote:
03 Jun 2018 02:58
sst wrote:
03 Jun 2018 02:09
XY Problem
How so?
If i understand right, what you wrote above:
You assume that "each time the program is called the command processor prints a blank line to the shell".
But this is only true for the topmost executable (batch/exe/...), so you won't see more than one additional lineend (carriage return + newline), no matter how many times or how you call that executable (call external file, call function, call *.exe, ...).

So trying to suppressing these (or better this single) blank lines (per topmost executable) can't solve the isssue you have (because it involves more than one single newline).

Proof:
"test.bat":

Code: Select all

@echo off
setlocal enableExtensions disableDelayedExpansion
for /l %%a in (1, 1, 100) do call "a.bat"
for /l %%a in (1, 1, 100) do call :b
for /l %%a in (1, 1, 100) do cmd /c"a.bat"
::...
goto :eof

:b
<nul set /p "=b"
"a.bat":

Code: Select all

@echo off
setlocal enableExtensions disableDelayedExpansion
<nul set /p "=a"
Result (cmd shell):

Code: Select all

Z:\>test.bat
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
Z:\>
penpen

sst
Posts: 93
Joined: 12 Apr 2018 23:45

Re: Stop Command Prompt Empty Line

#11 Post by sst » 03 Jun 2018 17:21

flywire wrote:
03 Jun 2018 02:58
sst wrote:
03 Jun 2018 02:09
XY Problem
How so?
Ignore this post if your are not interested to know how others may possibly interpret your post and how it is difficult to diagnose the problem and suggest solutions based on the kind of information that is provided.

In the next post I will try to diagnose and suggest a solution or at least try to narrow the search space to find the actual problem, It maybe wrong though because the information is not complete.

You have diagnosed the problem yourself and came to the conclusion that command processor is printing the blank lines to the screen then you decided to hide the details and just seeking for a solution of how to prevent command processor from printing blank lines, but didn't pay attention to the fact that the diagnostics maybe wrong and as a result others maybe put their efforts on solving a problem that is not the actual problem.

Even if the actual problem is what you think, the way you presented it does not suggest that to be true.

Let's start with your first post:
flywire wrote:
02 Jun 2018 05:41
I process thousands of files in a batch file with prog.exe ...
It just doesn't make sense. If someone unfamiliar with batch files sees this, hi/she would probably think that there are thousands of file references in a file called batch file which prog.exe is responsible for processing that batch file, But the ones who are familiar with subject can guess that prog.exe is somehow used inside of batch file but it is still unclear how that prog.exe is involved, what is it responsible for ? does it output something to the screen or it just do something to the files?
flywire wrote:
02 Jun 2018 05:41
and redirect output from the batch file to a log file
This part is clear (Maybe the only part)
flywire wrote:
02 Jun 2018 05:41
Each time the program is called the command processor prints a blank line to the shell.
At first glance this means that the program (prog.exe) is called from inside batch file and all of output of the batch file is redirected to a log file but despite the redirection it still prints blank lines to the console. It seems to be somewhat clear to this point (by guess) but since you related blank line output to calling the prog.exe it is still unclear why you made command processor responsible for printing the blank line to the console. How do you know the blank line is printed by command processor but not prog.exe. You didn't provide any evidence for your claim so others just have to guess or not relay on the incomplete and probably wrong information you provide. (Note that your later explanations made this even more vague and I personally can't decide with certainty what your actual problem is.)

Then comes the superuser site link refrence
flywire wrote:
02 Jun 2018 05:41
I found https://superuser.com/a/97308/514126
> set /p x=foo<nul
foo
> _
When I use it it just prints the program name 'prog' rather than running the program.

How can I suppress the blank lines in the shell?
You described that you've tried one of the solutions that is provided by that link. But It added even more to the confusion, just so you know. It is obvious that the solution you tried is not a solution at all but it is trowing out the question what you were trying to achieve with that? you probably was seeking the type of output that is provided by set /p but the thing your were seeking with set /p it is completely unrelated to what you have described before.

The question and answer on that link, Just trapped you in the in the same situation that you have created here yourself, and that's not your fault.
If it was to me I would down-vote both the answer and question on that link to at-least -1000 and prevented it to be indexed by search engines. Why? because The question does not provide any useful information or code samples to describe what the actual problem is. It is open to be interpreted in many ways, And the one who answered it just made an educated guess on what the questioner is seeking for and it just happened to be what he/she wanted and most probably in the wrong way.
Based on the text of the question which have no further details, you thought that it is addressing the very same problem you have. That's the problem with this kind of questions and answers.

I hope you see were it is going by providing incomplete and vague information on the problem. No one can read your mind and see the actual problem behind. You have to provide it yourself.

sst
Posts: 93
Joined: 12 Apr 2018 23:45

Re: Stop Command Prompt Empty Line

#12 Post by sst » 03 Jun 2018 18:46

flywire wrote:
02 Jun 2018 10:40
flywire wrote:
15 Feb 2018 04:46
...

Code: Select all

@echo off 
@echo off 
:: Usage: NestBat [File (without extension) [File (without extension)]] > Batling.bat 
:: 
:: Ver 15/02/2018 (CC BY-SA 4.0) 
:: 
echo Generating ...
:: 
For %%f in (%1*.dat) do ( 
  echo ::
  echo ::*** %%f 
  echo copy %%f DAT 
  echo copy %%f.dta DTA 
  echo copy %%f.dtt DTT 
  echo :: 
::   
  For %%g in (%2*.per) do ( 
    echo ::** %%g 
    echo copy %%g.per PER 
    echo Prog.exe 
    echo copy OUT %%f%%g.out 
    echo :: 
  ) 
  echo :: 
) 
echo done. 
:End 
Run Batling.bat as: Batling >Batling.log
I use 'Prog.exe' not 'echo Program'. I get thousands of blank lines written to the shell so the user just sees a blank screen.
What do you mean by: I use 'Prog.exe' not 'echo Program'
Does it mean in NestBat you replace echo Program with Prog.exe or replace it with echo Prog.exe or you mean something entirely different?
So it is unclear to me whether Prog.exe will be executed in the context of NestBat or Batling.bat?
I don't understand why didn't you just put Prog.exe in the above code yourself.

Based on what you have described before, It seems that Batling.bat is generated by the above batch file and Prog.exe is running in the context of Batling.bat (which means echo Prog.exe in NestBat) and you have problems when running Batling.bat

If it is running in the context of Batling.bat then reason for blank lines is obvious because in Batling.bat you didn't turn command echoing off. And again it is unclear whether it is intentional or not.
In that case the blank line output is not limited to just prog.exe as it happens with every other command that is running within Batling.bat like copy
But again in that case the blank lines must be redirected to Batling.log file not the screen.

If my above guess is right and also running Batling.bat with command echoing ON is not what you intended then try this code and report back

Code: Select all

@echo off 
:: Usage: NestBat [File (without extension) [File (without extension)]] > Batling.bat 
:: 
:: Ver 15/02/2018 (CC BY-SA 4.0) 
:: 
echo Generating ...>con
:: 
echo @echo off
For %%f in (%1*.dat) do ( 
  echo ::
  echo ::*** %%f 
  echo copy %%f DAT 
  echo copy %%f.dta DTA 
  echo copy %%f.dtt DTT 
  echo :: 
::   
  For %%g in (%2*.per) do ( 
    echo ::** %%g 
    echo copy %%g.per PER 
    echo Program 
    echo copy OUT %%f%%g.out 
    echo :: 
  ) 
  echo :: 
) 
echo done.>con
:End
However it prevents the blank lines to be appeared on Batlin.log file as the output is redirected. If after running Batling.bat>Batling.log blank lines are still appear on the Console SCREEN then the problem resides somewhere else.

flywire
Posts: 17
Joined: 14 Feb 2018 03:10

Re: Stop Command Prompt Empty Line

#13 Post by flywire » 04 Jun 2018 04:28

[edit:] The exe is a licenced commercial program. I have compiled a few programs in different languages and run them through the same batch file but they do not cause the blank line after each run. One attached here: [edit end]
Program.zip
This is how Program.exe should behave
(8 KiB) Downloaded 442 times
.
I see the forum is busy while I sleep and work.

* Forget the "I use 'Prog.exe' not 'echo Program'".
* NOTE: Batling.bat is run with echo on to get meaningful output in Batling.log.
* re XY problem - full filepaths are in quotes in this version but it does not affect this issue.

* Output has seven blank lines for six runs in both instances.
* Also note no blank line between the batch file command prompts - different to running an exe.

Code: Select all

Microsoft Windows [Version 10.0.17134.81]
(c) 2018 Microsoft Corporation. All rights reserved.

E:\bat\NestBat>NestBat > Batling.bat
E:\bat\NestBat>Batling > Batling.log







E:\bat\NestBat>NestBat2 > Batling2.bat
Generating ...
done.
E:\bat\NestBat>Batling2 > Batling2.log






E:\bat\NestBat>
Batling.bat

Code: Select all

echo Generating ... 
::
::*** E:\bat\NestBat\Best1 
copy "E:\bat\NestBat\Best1.dat" DAT 
copy "E:\bat\NestBat\Best1.dta" DTA 
copy "E:\bat\NestBat\Best1.dtt" DTT 
::** E:\bat\NestBat\High 
copy "E:\bat\NestBat\High.PER" PER 
Program 
copy OUT "E:\bat\NestBat\Best1_High.OUT" 
:: 
::** E:\bat\NestBat\Low 
copy "E:\bat\NestBat\Low.PER" PER 
Program 
copy OUT "E:\bat\NestBat\Best1_Low.OUT" 
:: 
:: 
::
::*** E:\bat\NestBat\Test2 
copy "E:\bat\NestBat\Test2.dat" DAT 
copy "E:\bat\NestBat\Test2.dta" DTA 
copy "E:\bat\NestBat\Test2.dtt" DTT 
::** E:\bat\NestBat\High 
copy "E:\bat\NestBat\High.PER" PER 
Program 
copy OUT "E:\bat\NestBat\Test2_High.OUT" 
:: 
::** E:\bat\NestBat\Low 
copy "E:\bat\NestBat\Low.PER" PER 
Program 
copy OUT "E:\bat\NestBat\Test2_Low.OUT" 
:: 
:: 
::
::*** E:\bat\NestBat\Test3 
copy "E:\bat\NestBat\Test3.dat" DAT 
copy "E:\bat\NestBat\Test3.dta" DTA 
copy "E:\bat\NestBat\Test3.dtt" DTT 
::** E:\bat\NestBat\High 
copy "E:\bat\NestBat\High.PER" PER 
Program 
copy OUT "E:\bat\NestBat\Test3_High.OUT" 
:: 
::** E:\bat\NestBat\Low 
copy "E:\bat\NestBat\Low.PER" PER 
Program 
copy OUT "E:\bat\NestBat\Test3_Low.OUT" 
:: 
:: 
echo done. 
Batling.log

Code: Select all

E:\bat\NestBat>echo Generating ...  
Generating ... 

E:\bat\NestBat>copy "E:\bat\NestBat\Best1.dat" DAT  
        1 file(s) copied.

E:\bat\NestBat>copy "E:\bat\NestBat\Best1.dta" DTA  
        1 file(s) copied.

E:\bat\NestBat>copy "E:\bat\NestBat\Best1.dtt" DTT  
        1 file(s) copied.

E:\bat\NestBat>copy "E:\bat\NestBat\High.PER" PER  
        1 file(s) copied.

E:\bat\NestBat>Program  
[program output]

E:\bat\NestBat>copy OUT "E:\bat\NestBat\Best1_High.OUT"  
        1 file(s) copied.

E:\bat\NestBat>copy "E:\bat\NestBat\Low.PER" PER  
        1 file(s) copied.

E:\bat\NestBat>Program  
[program output]

E:\bat\NestBat>copy OUT "E:\bat\NestBat\Best1_Low.OUT"  
        1 file(s) copied.

E:\bat\NestBat>copy "E:\bat\NestBat\Test2.dat" DAT  
        1 file(s) copied.

E:\bat\NestBat>copy "E:\bat\NestBat\Test2.dta" DTA  
        1 file(s) copied.

E:\bat\NestBat>copy "E:\bat\NestBat\Test2.dtt" DTT  
        1 file(s) copied.

E:\bat\NestBat>copy "E:\bat\NestBat\High.PER" PER  
        1 file(s) copied.

E:\bat\NestBat>Program  
[program output]

E:\bat\NestBat>copy OUT "E:\bat\NestBat\Test2_High.OUT"  
        1 file(s) copied.

E:\bat\NestBat>copy "E:\bat\NestBat\Low.PER" PER  
        1 file(s) copied.

E:\bat\NestBat>Program  
[program output]

E:\bat\NestBat>copy OUT "E:\bat\NestBat\Test2_Low.OUT"  
        1 file(s) copied.

E:\bat\NestBat>copy "E:\bat\NestBat\Test3.dat" DAT  
        1 file(s) copied.

E:\bat\NestBat>copy "E:\bat\NestBat\Test3.dta" DTA  
        1 file(s) copied.

E:\bat\NestBat>copy "E:\bat\NestBat\Test3.dtt" DTT  
        1 file(s) copied.

E:\bat\NestBat>copy "E:\bat\NestBat\High.PER" PER  
        1 file(s) copied.

E:\bat\NestBat>Program  
[program output]

E:\bat\NestBat>copy OUT "E:\bat\NestBat\Test3_High.OUT"  
        1 file(s) copied.

E:\bat\NestBat>copy "E:\bat\NestBat\Low.PER" PER  
        1 file(s) copied.

E:\bat\NestBat>Program  
[program output]

E:\bat\NestBat>copy OUT "E:\bat\NestBat\Test3_Low.OUT"  
        1 file(s) copied.

E:\bat\NestBat>echo done.  
done. 
NestBat2.bat

Code: Select all

@echo off
:: Usage: NestBat2 [File (without extension) [File (without extension)]] > Batling2.bat
::
:: Ver 15/02/2018 (CC BY-SA 4.0)
::
echo Generating ...>con
::
echo @echo off
for %%F in ("%1*.dat") do (
  echo ::
  echo ::*** %%~pdnF
  echo copy "%%~pdnF.dat" DAT
  echo copy "%%~pdnF.dta" DTA
  echo copy "%%~pdnF.dtt" DTT
::
  for %%G in ("%2*.per") do (
    echo ::** %%~pdnG
    echo copy "%%~pdnG.PER" PER
    echo Program
    echo copy OUT "%%~pdnF_%%~nG.OUT"
    echo ::
  )
  echo ::
)
echo done.>con
:End
Batling2.bat

Code: Select all

@echo off
::
::*** E:\bat\NestBat\Best1
copy "E:\bat\NestBat\Best1.dat" DAT
copy "E:\bat\NestBat\Best1.dta" DTA
copy "E:\bat\NestBat\Best1.dtt" DTT
::** E:\bat\NestBat\High
copy "E:\bat\NestBat\High.PER" PER
Program
copy OUT "E:\bat\NestBat\Best1_High.OUT"
::
::** E:\bat\NestBat\Low
copy "E:\bat\NestBat\Low.PER" PER
Program
copy OUT "E:\bat\NestBat\Best1_Low.OUT"
::
::
::
::*** E:\bat\NestBat\Test2
copy "E:\bat\NestBat\Test2.dat" DAT
copy "E:\bat\NestBat\Test2.dta" DTA
copy "E:\bat\NestBat\Test2.dtt" DTT
::** E:\bat\NestBat\High
copy "E:\bat\NestBat\High.PER" PER
Program
copy OUT "E:\bat\NestBat\Test2_High.OUT"
::
::** E:\bat\NestBat\Low
copy "E:\bat\NestBat\Low.PER" PER
Program
copy OUT "E:\bat\NestBat\Test2_Low.OUT"
::
::
::
::*** E:\bat\NestBat\Test3
copy "E:\bat\NestBat\Test3.dat" DAT
copy "E:\bat\NestBat\Test3.dta" DTA
copy "E:\bat\NestBat\Test3.dtt" DTT
::** E:\bat\NestBat\High
copy "E:\bat\NestBat\High.PER" PER
Program
copy OUT "E:\bat\NestBat\Test3_High.OUT"
::
::** E:\bat\NestBat\Low
copy "E:\bat\NestBat\Low.PER" PER
Program
copy OUT "E:\bat\NestBat\Test3_Low.OUT"
::
::
Batling2.log

Code: Select all

        1 file(s) copied.
        1 file(s) copied.
        1 file(s) copied.
        1 file(s) copied.
[program output]
        1 file(s) copied.
        1 file(s) copied.
[program output]
        1 file(s) copied.
        1 file(s) copied.
        1 file(s) copied.
        1 file(s) copied.
        1 file(s) copied.
[program output]
        1 file(s) copied.
        1 file(s) copied.
[program output]
        1 file(s) copied.
        1 file(s) copied.
        1 file(s) copied.
        1 file(s) copied.
        1 file(s) copied.
[program output]
        1 file(s) copied.
        1 file(s) copied.
[program output]
        1 file(s) copied.
Last edited by flywire on 04 Jun 2018 16:02, edited 1 time in total.

sst
Posts: 93
Joined: 12 Apr 2018 23:45

Re: Stop Command Prompt Empty Line

#14 Post by sst » 04 Jun 2018 10:40

Based on the contents of the batch files and the outputs you have posted, Your executable is responsible for printing blank lines to the console.

But since the output is redirected, I can think of two reasons for that behavior:
1. Prog.exe is printing blank line to the stderr
2. Prog.exe is directly writing to the console (at-least for that blank line) so it's output can not be redirected.

In your NestBat

Code: Select all

echo Prog.exe 2^>nul
Or better directly in Batling.bat

Code: Select all

Prog.exe 2>nul
and see if that eliminates the blank lines or not. If that doesn't help then you need another workaround.
Last edited by sst on 04 Jun 2018 10:57, edited 1 time in total.

pieh-ejdsch
Posts: 239
Joined: 04 Mar 2014 11:14
Location: germany

Re: Stop Command Prompt Empty Line

#15 Post by pieh-ejdsch » 04 Jun 2018 10:55

I once tinkered with your createNest, because I first had to understand what should be done when.
In addition, I had to create a similar test environment. Unfortunately, I do not have the "program" there.
First of all, I can only repeat myself with the "program" quarreling around it.
all other issues are fine and do not bring any extra blank lines into any output.

Code: Select all

:: Create NestBat.bat and demo files
::
:: Ver 15/02/2018 (CC BY-SA 4.0)
::
@ ( setlocal
set prompt=$g$s)
@echo off
echo create NestBat and demo files
mkdir NestBat
cd NestBat
call :createNestBat >NestBat.bat
cd ..
echo done ...
pause
exit /b

:createNestBat
echo @echo off
echo ::
echo :: Usage: NestBat [File (without extension) [File (without extension)]]
echo ::
echo :: Ver 15/02/2018 (CC BY-SA 4.0)
echo ::
echo @ ( setlocal
echo set prompt=$g$s)
echo echo Generating ...
echo call :createBatling %%1 %%2 ^>Batling.bat
echo echo done ...
echo exit /b
echo :createBatling
echo For %%%%f in (%%1*.dat) do (
echo   echo :: make one DAT DTA DTT
echo   echo ::*** %%%%~dpnf
echo   echo copy %%%%~ff DAT
echo   echo copy %%%%~dpnf.dta DTA
echo   echo copy %%%%~dpnf.dtt DTT
echo ::
echo   For %%%%g in (%%2*.per) do (
echo     echo :: every DAT - make n PER
echo     echo ::** %%%%~dpng
echo     echo copy %%%%~fg PER
echo     echo Program
echo     echo copy OUT %%%%~dpnf_%%%%~ng.out
echo     echo ::
echo   )
echo   echo ::****  end %%%%~nf
echo   echo ::
echo )
:END createNestBat

:: Test Files
for %%i in ( Best1.dat
 Best1.dta
 Best1.dtt
 Test2.dat
 Test2.dta
 Test2.dtt
 Test3.dat
 Test3.dta
 Test3.dtt
 High.per
 Low.per
 OUT ) do >%%i echo

Your sample expenses are not good to exploit, because the redirect has arrived in the LOG.
Leave the diversion first so that you get to see the complete output in the command line.
You can use that better.
put your line at the beginning with REM to let the "program" do nothing first -so you see immediately what it is.

Post Reply