Thanks for the response.
I used your code and not able to print what I actually require
@echo off
setlocal enabledelayedexpansion
set WORKING_DIRECTORY=%cd%
pushD %WORKING_DIRECTORY%
REM echo %WORKING_DIRECTORY%
for /f "usebackq tokens=*" %%a in (`dir /b/s/a:d MigrationPoc`) do (
echo:%%~nxa
set "vfolder=%%~nxa"
for /f "usebackq tokens=*" %%a in (`dir /a-d /b %%a` ) do (
echo %%a
echo:%%~na
set vfilenamewithext=%%a
set vfilename=%%~na
set /p "header="<"!vfilenamewithext!"
set "header=%header:|=,%"
FOR /F "skip=1 usebackq delims=" %%G IN ("!vfilenamewithext!") DO (
set "line=%%~G"
set line="!line:|=","!"
echo %header%##!line!##!vfolder!.!vfilename!
)
)
)
pause
popD
But issue with reading the file persists and I cannot able to print the line number along with file contents also.
My output is:
F1
u1.sql
u1
REM THE FILE f1 contains
COMPID|COMPNAME|ADDRESS|YEAROFESTABLISTMENT
100|XYC|AWER RD|12072018
120|BNM|PQTY RD|12082018
rem sample output:
COMPID,COMPNAME,ADDRESS,YEAROFESTABLISTMENT##"100","XYC","AWER RD","12072018"##F1.u1##<line no> 2
COMPID,COMPNAME,ADDRESS,YEAROFESTABLISTMENT##"120","BNM","PQTY RD","12082018"##F1.u1##<line no> 3
The system cannot find the file specified.
The system cannot find the file u1.sql.
b1.sql
b1
The system cannot find the file specified.
The system cannot find the file b1.sql.
c1.sql
c1
The system cannot find the file specified.
The system cannot find the file c1.sql.
d1.sql
d1
The system cannot find the file specified.
The system cannot find the file d1.sql.
Sch_B
File Not Found
Sch_C
File Not Found
Sch_D
a1.sql
a1
The system cannot find the file specified.
The system cannot find the file a1.sql.
b1.sql
b1
The system cannot find the file specified.
The system cannot find the file b1.sql.
c1.sql
c1
The system cannot find the file specified.
The system cannot find the file c1.sql.
d1.sql
d1
The system cannot find the file specified.
The system cannot find the file d1.sql.
Note if the folder contains no file i need to skip that folder which is not happening.