1.

Solve : batch generate txt log file?

Answer»

Hi i have a problem creating a batch file.
what am i trying to do?

from this FS
Code: [Select]folder tree
2008-02-20-NV\HF_20080220G
├───2008-08-22A_MIHAJ_KAD&OD_JS_#1
├───2008-09-17A_NG_FE_FIN
├───2008-09-18A_MIHAJ_OD_JS_#1 za podverzijo G
│ └───##FS

i am trying to :
create a txt file that contains:
- summary of subfolders with tags (FS, SQL and MENU)
- detailed list with summaries all in one file named after parent dir

so from example this would look something like
Code: [Select]VER: HF_20080220G

2008-08-22A_MIHAJ_KAD&OD_JS_#1 MENU
2008-09-17A_NG_FE_FIN SQL
2008-09-18A_MIHAJ_OD_JS_#1 za podverzijo G FS SQL

---------------------------------------------
2008-08-22A_MIHAJ_KAD&OD_JS_#1

text from berime.txt file on 2008-08-22A_MIHAJ_KAD&OD_JS_#1
-----------------------------------------------
2008-09-17A_NG_FE_FIN

text from berime.txt file on 2008-09-17A_NG_FE_FIN
-----------------------------------------------
2008-09-18A_MIHAJ_OD_JS_#1 za podverzijo G

text from berime.txt file on 2008-09-18A_MIHAJ_OD_JS_#1 za podverzijo G
-----------------------------------------------

I got stuck somewhere here:

Code: [Select]@echo off
cls
for %%i in (".") do (
set pot_NV=%%~fsi
set dat_ime=%pot_NV%\%%~ni.logx
echo VER: %%~ni >%dat_ime%
echo ****************************************** >>%dat_ime%
)


for /F %%j in ('dir *. /a:d /b') do (
if not %%~nj==##FS (
echo:%%~nj >>%dat_ime%
)
)

echo: >>%dat_ime%
echo: >>%dat_ime%
echo ************ po Hotfixih****************** >>%dat_ime%
for /F %%j in ('dir *. /a:d /b') do (
if not %%~nj==##FS (
echo ------------------------------------------ >>%dat_ime%
echo:%%~nj >>%dat_ime%
if exist %%~fsj\berime.txt (
echo: >>%dat_ime%
type %%~fsj\berime.txt >>%dat_ime%
echo: >>%dat_ime%
)
)
)

pause
echo on
@type %dat_ime%

in win2003 server this batch file is giving out ERR syntax of the command is incorrect ... don't know why (? i think that %dat_ime% is not set ?).

--- help with the err
--- and how can i set the FS, SQL or MENU tags?

with tags i came with

Code: [Select]for /F %%j in ('dir *. /a:d /b') do (
if not %%~nj==##FS (
echo:%%~nj >>%dat_ime%
for /F %%K in ('dir %%~fsj\*.sql /b') do (
echo: SQL >>%dat_ime%
)
for /F %%l in ('dir %%~fsj\##FS /a:d /b') do (
echo: FS >>%dat_ime%
)

)
)

but this turns out many SQL tags and i don't know how to brake for statement after first echo.

thanks for any info ...

P.s.:
system win 2003 server SP2 (32bit) ok.
found the err part
It was %%~FI (long path name) it should have been %%~fsi (short names)
and .logx where dos doesn't always GET 4 char ext

so i am here:
Code: [Select]@echo off
cls
for %%i in (".") do (
set pot_NV=%%~fsi
set dat_ime=%%~ni.log
)
set dat_ime=%pot_NV%\%dat_ime%

echo VER: %dat_ime% >%dat_ime%
echo ****************************************** >>%dat_ime%


for /F %%j in ('dir *. /a:d /b') do (
if not %%~nj==##FS (
echo:%%~nj >>%dat_ime%
for /F %%k in ('dir %%~fsj\*.sql /b') do (
echo: SQL >>%dat_ime%
)
for /F %%l in ('dir %%~fsj\##FS /a:d /b') do (
echo: FS >>%dat_ime%
)
)
)

echo: >>%dat_ime%
echo: >>%dat_ime%
echo ************ po Hotfixih****************** >>%dat_ime%
for /F %%j in ('dir *. /a:d /b') do (
if not %%~nj==##FS (
echo ------------------------------------------ >>%dat_ime%
echo:%%~nj >>%dat_ime%
if exist %%~fsj\berime.txt (
echo: >>%dat_ime%
type %%~fsj\berime.txt >>%dat_ime%
echo: >>%dat_ime%
)
)
)

cls
echo LOG complete!
echo %dat_ime%
pause
echo on
@rem @type %dat_ime%

still looking for:
- how to continue a row in FOR statemen, so that i can have
Code: [Select]2008-09-18A_MIHAJ_OD_JS_#1 FS SQL
instead of
Code: [Select]2008-09-18A_MIHAJ_OD_JS_#1
FS
SQL

- a way to break FOR statemen, so that I don't get 'SQL' for every *.sql file there is in a specific subfolder
- how to find "MENU" in berime.txt in subfolder.

the LAST should look something like
Code: [Select] for /F %%k in ('%%~fsj\*.berime.txt') do (
???????
)

but i am stuck here. (don't know how to search for text "MENU" in txt file)

thanks for any info



Discussion

No Comment Found