DeE DEe
DeE DEe

Reputation: 335

Batch file to extract date from txt file

I have a text file.

AML.DATA|01-JUN-2016
PORT_DATA|560538
NDB_AML_AA|43063
NDB_AML_LD|12878
NDB_AML_REPO|496
NDB_AML_TRAN|84596
NDB_AML_JOINT_AC|219873
NDB_AML_CUS_REL_PRTY|43
NDB_AML_BICCODE|108292
CUSTOMER_MASTER|684124
CATEGORY.MASTER|3288
DEPT.MASTER|2527
COUNTRY.MASTER|251
CUSTOMER.STATUS.MASTER|26
INDUSTRY.MASTER|65
JOB.TITLE.MASTER|22
COMPANY.MASTER|121
TRANSACTION.MASTER|3133
RELATION.MASTER|56
NDB_AML_TBILL_TBOND|2845
EOF

I want to extract the date part (01-JUN-2016) from the text file. How can I do it?

Upvotes: 0

Views: 387

Answers (1)

npocmaka
npocmaka

Reputation: 57252

if the date is always on the first line:

@echo off
<file set /p line=
echo "%line%"
for /f "tokens=2 delims=|" %%# in ("%line%") do set "_date=%%#"
echo %_date%

Upvotes: 1

Related Questions