looking for better oubut on batch file

February 3, 2010 at 21:35:39
Specs: Windows XP, 3.0
Hi folks,

I am very new to batch programming & looking for your co-operation...

I have in my 'compile_schema.txt' following data

LS001/m_m_001_01/m_001_01_01_co.fla
LS001/m_m_001_01/m_001_01_02_co.fla
LS001/m_m_001_01/m_001_01_03_co.fla

line by line i want to break this data line wise & print like as follow in DOS when i will run batch file

BUILDFILE LS001/build_m_m_001_01.xml
BUILDFILE LS001/build_m_m_001_02.xml
BUILDFILE LS001/build_m_m_001_03.xml


here want i have done & still what with i strugling

for /f "tokens=1,2 delims=/" %%a in (compile_schema.txt) do ( echo BUILDFILE %%a/build_%%b.xml )

this gives

following when i run file batch file :

BUILDFILE LS001/build_m_m_001_01.xml
BUILDFILE LS001/build_m_m_001_01.xml
BUILDFILE LS001/build_m_m_001_01.xml

But iwant it should give Outfut

BUILDFILE LS001/build_m_m_001_01.xml
BUILDFILE LS001/build_m_m_001_02.xml
BUILDFILE LS001/build_m_m_001_03.xml

looking for reply...

Regards,
Ganesh


See More: looking for better oubut on batch file

Report •

#1
February 4, 2010 at 01:44:07
I got your private message. Here the solution

@echo off & setlocal EnableDelayedExpansion
for /F "tokens=1,3 delims=/" %%a in (compile_schema.txt) do (
  set row=BUILDFILE %%a/build_%%c
  set row=!row:~0,-7!.xml
  edho.!row!
)


Report •

#2
February 4, 2010 at 01:53:23
Please wait, the previous post is incorrect... I am replacing thr code with the right version.

Report •

#3
February 4, 2010 at 02:11:52
@echo off & setlocal EnableDelayedExpansion
for /F "tokens=1-3 delims=/" %%a in (compile_schema.txt) do (
  set B=%%b
  set B=!B:~0,-3!
  set C=%%c
  set C=!C:~-9,2!
  echo.BUILDFILE %%a/build_!B!_!C!.xml
)


Report •

Related Solutions

#4
February 4, 2010 at 02:36:32

Anyone know any Batch file command for printing all content of DOS Screen into some text file.

Like as suppose .. my DOS Screen contain following text,


.................. Creating Build for Multiple Modules listed in compile_schema.txt ..................

................. Build started for: LS001/build_m_m_001_01 .................


Buildfile: LS001\build_m_m_001_01.xml
[echo] FLEX_HOME -> :E:\Bertelsmann\newVSS\05 WIP\SCOYO\build\LS001: (remember to call ant -DFLEX_HOME=...)

clean:

validateManifests:
[xmlvalidate] 1 file(s) have been successfully validated.

deployAssets:
[echo] Please make sure to copy all needed assets to the output folder (bin)!
[mkdir] Created dir: E:\Bertelsmann\newVSS\05 WIP\SCOYO\bin\com\tis\LS001\m_m_001_01\assets
[copy] Copying 173 files to E:\Bertelsmann\newVSS\05 WIP\SCOYO\bin\com\tis\LS001\m_m_001_01\assets
[copy] Copied 5 empty directories to 1 empty directory under E:\Bertelsmann\newVSS\05 WIP\SCOYO\bin\com\tis\LS001\m_m_
[copy] Copying 1 file to E:\Bertelsmann\newVSS\05 WIP\SCOYO\bin\com\tis\LS001\m_m_001_01

buildModules:
[mxmlc] Loading configuration file E:\Bertelsmann\newVSS\05 WIP\SCOYO\build\module-config.xml
[mxmlc] Initial setup: 31ms
[mxmlc] Loaded 13 SWCs: 1078ms
[mxmlc] Files: 484 Time: 6938ms
[mxmlc] Linking... 234ms
[mxmlc] Optimizing... 203ms
[mxmlc] SWF Encoding... 235ms
[mxmlc] E:\Bertelsmann\newVSS\05 WIP\SCOYO\bin\com\tis\LS001\m_m_001_01\m_m_001_01_01_co.swf (1169236 bytes)
[mxmlc] Total time: 8734ms
[mxmlc] Peak memory usage: 72 MB (Heap: 42, Non-Heap: 30)
[mxmlc] Loading configuration file E:\Bertelsmann\newVSS\05 WIP\SCOYO\build\module-config.xml
[mxmlc] Initial setup: 187ms
[mxmlc] Loaded 13 SWCs: 657ms
[mxmlc] Files: 485 Time: 5531ms

it should print this complete text at last into some new text file.

Regards,
Ganesh


Report •

#5
February 4, 2010 at 03:17:11
First of all there is no DOS in Windows XP as it is a NT kernel system. What you believe a DOS box is actually the System Console driven by cmd.exe, the text command interpreter, and is a graphic window simulating textual interface.

So stated the only way to achieve what you want is to try to run your application redirecting its output to a text file, i.e. if the application is e.g. a compiler named smartADA

smartADA S:C:\mysource /LIB:stdlibADA > CompOUT.txt

That has a drawback: if the application prompts for actions the request text is not displayed to the screen.

By the way did the code to parse the text file help you?


Report •

#6
February 4, 2010 at 03:32:29
Hi IVO,

Thanks for your nice co-operation but before your posting i had solved my querry below is solution

=============================================

@echo off

REM Inorder to use build_multi.bat, the compile_schema.txt should be present with the list of modules to be built, in the root

set ANT_HOME=E:\Bertelsmann\Build\apache-ant-1.7.0
set JAVA_HOME=C:\Program Files\Java\jre1.6.0
set JAVACMD=%JAVA_HOME%\bin\java.exe

setLocal EnableDelayedExpansion

echo.
echo.
echo.
echo [TIS] .................. Creating Build for Multiple Modules listed in compile_schema.txt ..................
echo.
echo.
for /f "tokens=1-9 delims=/_" %%a in (compile_schema.txt) do (

REM echo BUILDFILE %%a/build_%%b_%%c_%%d_%%i.xml
REM SET LS=%%a
REM echo %!LS!
REM SET MODULE=%%b_%%c_%%d_%%i
REm echo %!MODULE!
echo [TIS] ................. Build started for: %%a/build_%%b_%%c_%%d_%%i .................
echo.
echo.
set TASK=buildAll
set OPTS=-Xms512m -Xmx512m -XX:MaxPermSize=256m
"%JAVACMD%" %OPTS% -classpath "%ANT_HOME%\lib\ant-launcher.jar" "-Dant.home=%ANT_HOME%" org.apache.tools.ant.launch.Launcher %ANT_ARGS% %ANT_CMD_LINE_ARGS% -buildfile "%%a/build_%%b_%%c_%%d_%%i.xml" %TASK%
echo.
echo.
echo **************************************************************************************
echo.
echo.
echo.

smartADA S: > CompOUT.txt

)

pause
=============================================


however i tried your command,

smartADA S:C:\mysource /LIB:stdlibADA > CompOUT.txt

but it not work following is output


BUILDFILE LS001/build_m_m_001_01.xml
LS001
m_m_001_01
BUILDFILE LS001/build_m_m_001_02.xml
LS001
m_m_001_02
BUILDFILE LS001/build_m_m_001_03.xml
LS001
m_m_001_03
BUILDFILE LS001/build_m_m_001_04.xml
LS001
m_m_001_04
BUILDFILE LS001/build_m_m_001_05.xml
LS001
m_m_001_05
BUILDFILE LS001/build_m_m_001_06.xml
LS001
m_m_001_06
'smartADA' is not recognized as an internal or external command,
operable program or batch file.

Creating Build for files in Module C:\DOCUME~1\ganeshk\LOCALS~1\Temp to the Ser
er


Press any key to continue . . .


Your help will be highly appreciated



Report •

#7
February 4, 2010 at 03:33:58
IVO,

looking for your help!!

Regards,
Ganesh


Report •

#8
February 4, 2010 at 03:57:04
Let me see... See you as soon.

Report •

#9
February 4, 2010 at 04:00:13
Process is like this for understanding

This my rnd.bat

@echo off

echo. my name is Kha
echo Creating Build for files in Module %temp% to the Server
echo. Call some php file contenet
echo. Call some java file contenet

here their would be some command which print all data in txt file
pause

when i execute it should show
.................................................
my name is Kha
Creating Build for files in Module %temp% to the Server

php code
fsdfs
fs
fsdf
sf
sf
sd
end php code

java code
fsdfs
fs
fsdf
sf
sf
sd
end java code
....................................................

now this at last it should copy this all executed content into some txt file



Report •

#10
February 4, 2010 at 04:05:22
Be patient, I will examine your issue later as now I have another duty to attend. Be sure I will give you an answer ( I hope a solution).

Report •

#11
February 4, 2010 at 04:07:57
Cool ......... :)

Report •

#12
February 4, 2010 at 09:17:43

Here what I have worked out, but, please, listen to me carefully.

The only way to achieve your target is redirect the standard output from console (screen) to a file using the redirector symbol > and >>. This works if the command line co,piler uses stdin/out handles to manage input/output.

When I posted "smartADA" command that was just an example using an imaginary ADA compiler NOT a real command. I modified the code you posted that, pay attention, contained errors in managing dynamic variables too (variables marked by ! and enabled by setlocal statement).

The script you find below should work, but the process to redirect to file is not easily managed by non experienced coders as it seems you are (please, I do not want to offend anyway). Examine it carefully and try to understand the use of the redirectors (>/>>) if you have to use them in your scripts.

In one word the batch redirects screen text to compile_out.txt (or the name you like) and when completed displays the file onto screen via the "more" command.

Any way I am here. Please contact me by a private message with your e.mail address as I prefer to send the text as attachment.

@echo off

set OUT=compile_out.txt
tyoe nul > %OUT%

REM In order to use build_multi.bat, the compile_schema.txt should
REM be present with the list of modules to be built in the root.

set ANT_HOME=E:\Bertelsmann\Build\apache-ant-1.7.0
set JAVA_HOME=C:\Program Files\Java\jre1.6.0
set JAVACMD=%JAVA_HOME%\bin\java.exe

set TASK=buildAll
set OPTS=-Xms512m -Xmx512m -XX:MaxPermSize=256m
(
echo.
echo.[TIS] ... Creating Build for Multiple Modules listed in compile_schema.txt ...
echo.
) >> %OUT%

for /F "tokens=1-9 delims=/_" %%a in (compile_schema.txt) do (
  echo.[TIS] ... Build started for: %%a/build_%%b_%%c_%%d_%%i ...
  echo.
  "%JAVACMD%" %OPTS% -classpath "%ANT_HOME%\lib\ant-launcher.jar" "-Dant.home=%ANT_HOME%" org.apache.tools.ant.launch.Launcher %ANT_ARGS% %ANT_CMD_LINE_ARGS% -buildfile "%%a/build_%%b_%%c_%%d_%%i.xml" %TASK%
  echo.
  echo ****************************************************************************
  echo.
) >> %OUT%

more %OUT%
pause


Report •

#13
February 4, 2010 at 21:53:31
Hi IVO,

Bunch of thanks ...

Worderful but your code only gives output in ouput.txt & nothing visual content on DOS screen I want both the places Dos Sceen as well in output.txt ..here is whati have done till & working but still i am looking a great solution to see output both the end & I am sure that you will definately provide a better solution to me

====================================

@echo off

REM Inorder to use build_multi.bat, the compile_schema.txt should be present with the list of modules to be built, in the root

set ANT_HOME=E:\Bertelsmann\Build\apache-ant-1.7.0
set JAVA_HOME=C:\Program Files\Java\jre1.6.0
set JAVACMD=%JAVA_HOME%\bin\java.exe

setLocal EnableDelayedExpansion

del "build_multi_log.txt"
>>"build_multi_log.txt" echo.
>>"build_multi_log.txt" echo.
>>"build_multi_log.txt" echo.

echo.
echo.
echo.

>>"build_multi_log.txt" echo [TIS] .................. Creating Build for Multiple Modules listed in compile_schema.txt ..................
>>"build_multi_log.txt" echo.
>>"build_multi_log.txt" echo.

echo [TIS] .................. Creating Build for Multiple Modules listed in compile_schema.txt ..................
echo.
echo.

for /f "tokens=1-9 delims=/_" %%a in (compile_schema.txt) do (
REM echo BUILDFILE %%a/build_%%b_%%c_%%d_%%i.xml
REM SET LS=%%a
REM echo %!LS!
REM SET MODULE=%%b_%%c_%%d_%%i
REm echo %!MODULE!
>>"build_multi_log.txt" echo Creating Build for files in Module %%b_%%c_%%d_%%i to the Server
echo Creating Build for files in Module %%b_%%c_%%d_%%i to the Server
set TASK=buildAll
set OPTS=-Xms512m -Xmx512m -XX:MaxPermSize=256m

>>"build_multi_log.txt" "%JAVACMD%" %OPTS% -classpath "%ANT_HOME%\lib\ant-launcher.jar" "-Dant.home=%ANT_HOME%" org.apache.tools.ant.launch.Launcher %ANT_ARGS% %ANT_CMD_LINE_ARGS% -buildfile "%%a/build_%%b_%%c_%%d_%%i.xml" %TASK%
"%JAVACMD%" %OPTS% -classpath "%ANT_HOME%\lib\ant-launcher.jar" "-Dant.home=%ANT_HOME%" org.apache.tools.ant.launch.Launcher %ANT_ARGS% %ANT_CMD_LINE_ARGS% -buildfile "%%a/build_%%b_%%c_%%d_%%i.xml" %TASK%

>>"build_multi_log.txt" echo [TIS] ................. Build tried for: %%a/build_%%b_%%c_%%d_%%i.xml .................
>>"build_multi_log.txt" echo **************************************************************************************
>>"build_multi_log.txt" echo.
>>"build_multi_log.txt" echo.
>>"build_multi_log.txt" echo.

echo [TIS] ................. Build tried for: %%a/build_%%b_%%c_%%d_%%i.xml .................
echo **************************************************************************************
echo.
echo.
echo.
)

pause
=========================================


Report •

#14
February 4, 2010 at 22:01:58
there is a utility called Tee which will split output, also implemented in windows as a gnu utility. you might google that and see what emerges. I forget the syntax of using it, but basically you can make two outputs, one to file, other to stdio.
(nothing serious about it, it just reads std input, echos to stdout, and echos to %1, or something along that line.)

Report •

#15
February 4, 2010 at 22:05:34
I kin to see that let me know if you get something...
Right now as well user unable to see output on Dos screen instead they only can see inside output.txt do let me know if any solution u had..

Report •

#16
February 4, 2010 at 22:18:39
here's one:
http://users.csc.calpoly.edu/~bfrie...
(scroll down to 'tee')
there's bunch more... google "tee dos"

Report •

#17
February 5, 2010 at 00:07:50
Hi nbrane,

I Have “list .txt” that contains following folder structure which I need to copy,
LS001/m_m_001_01/m_001_01_01_co.fla
LS001/m_m_001_01/m_001_01_02_co.fla
LS001/m_m_001_01/m_001_01_03_co.fla
LS002/m_m_002_01/m_002_01_03_co.fla
LS002/m_m_002_07/m_002_07_03_co.fla
LS006/m_m_006_03/m_006_03_03_co.fla
Through batch process I want to make copy of this folder into two different folders like as below
Main is Root Folder in that
1st folder is,
bin/com/tis/ LS001/m_m_001_01/m_001_01_01_co.fla
bin/com/tis/ LS001/m_m_001_01/m_001_01_02_co.fla
.
… likewise till
bin/com/tis/ LS006/ m_m_006_03/m_006_03_03_co.fla

& 2nd folder,
src/com/tis/ LS001/m_m_001_01/m_001_01_01_co.fla
src/com/tis/ LS001/m_m_001_01/m_001_01_02_co.fla
.
… likewise till
src/com/tis/ LS006/ m_m_006_03/m_006_03_03_co.fla
Can anyone have any idea ?????????????????

Regards,
Ganesh


Report •

#18
February 5, 2010 at 02:24:08
hello Ganesh:
@echo off & setlocal
set xx=bin
call :mv
set xx=src
call :mv
goto :eof

:mv
for /f %%a in (list.txt) do (
copy %%a %xx%/com/tis/%%a
)

assuming this is not on unix platform, the slashes might need to be adjusted (/ to \).
waiting for the other shoe to drop! ;)


Report •

#19
February 5, 2010 at 02:58:20
If you have the output stored in a text file to display its content onto screen just "type" it or better use "more" to control scrolling.

That is just what I coded and this way proved to be effective in other scripts.

When you modify a code be aware to clearly understand the meaning of statements as in software "to be closer" doesn't exist.


Report •

#20
February 7, 2010 at 21:53:25
Hi nbrane,

I Have “list .txt” that contains following folder structure which I need to copy into Some another folders(that is it only contain location of few files here below i shown in directory format),

LS001/m_m_001_01/m_001_01_01_co.fla
LS001/m_m_001_01/m_001_01_02_co.fla
LS001/m_m_001_01/m_001_01_03_co.fla
LS002/m_m_002_01/m_002_01_03_co.fla
LS002/m_m_002_07/m_002_07_03_co.fla
LS006/m_m_006_03/m_006_03_03_co.fla

Through batch process I want to make copy of this folders into two different folders like as below

Main is Root Folder in that

1st folder is,
bin/com/tis/ inside this it will get copy LS001/m_m_001_01/m_001_01_01_co.fla
bin/com/tis/ inside this it will get copy LS001/m_m_001_01/m_001_01_02_co.fla
.
… likewise till
bin/com/tis/ inside this it will get copy LS006/ m_m_006_03/m_006_03_03_co.fla

& 2nd folder,
src/com/tis/ inside this it will get copy LS001/m_m_001_01/m_001_01_01_co.fla
src/com/tis/ inside this it will get copy LS001/m_m_001_01/m_001_01_02_co.fla
.
… likewise till
src/com/tis/ inside this it will get copy LS006/ m_m_006_03/m_006_03_03_co.fla


here what i try now but still not copying in directory doing somthing wrong ..

@echo off

setLocal EnableDelayedExpansion

xx=bin
call :mv
xx=src
call :mv
goto :eof

:mv
for /f %%a in (compile_schema.txt) do (
rem copy LS001\m_m_001_01\
rem %xx%\com\tis\LS001\m_m_001_01\
rem copy %%a %xx%/com/tis/%%a
xcopy ../bin/com/tis/*.*
)

pause

This copy to root & not inside mentioned 'SRC' *& 'Bin' folder


Report •

#21
February 7, 2010 at 22:57:49
my mistake, sorry!

:mv
for /f %%a in (list.txt) do (
copy %%a %xx%/com/tis/%%a
)
change to:
:mv
for /f %%a in (list.txt) do (
copy %%a !xx!/com/tis/%%a
)

not sure this will fix it (ie: not tested), but give it a shot.

not sure what's going on here, since xcopy doesn't seem to be syntactically correct... but i may be wrong...
:mv
for /f %%a in (compile_schema.txt) do (
rem copy LS001\m_m_001_01\
rem %xx%\com\tis\LS001\m_m_001_01\
rem copy %%a %xx%/com/tis/%%a
xcopy ../bin/com/tis/*.*
)

ie: xcopy: no destination?


Report •

Ask Question