Fetching colum data with concat file Name

[Closed]
Report
-
 Hawk -
Hi ,

i am new to Batchscripting. can anyone help me to resolve the below issue.

I have some files in c:\SCM directory. please find below of them.
Strom_u.dat
Strom_G.dat
Strom_C.dat

in Strom_u.dat we have data like:
1001|Nagi|SE
1002|Hari|SSE
1003|Chakri|PL

now i want to create a file in the same path like :
1001|Strom_U
1002|Strom_U
1003|Strom_U

Thanks in Advance.

Regards,
Nagi.

1 reply

You can try this,

Put the bat file in the same folder.

@echo off
for /f "tokens=* delims=" %%h in ('dir/b/a-d "Your folder path" ^| find ".txt"') do (
for /f "tokens=1-6 delims=|" %%n in ('findstr /i /c:"|" "%%h"') do echo %%n^|%%~nh >> newfile.txt
)
)


Regards - Pradeep