-1

Through windows batch file, I am trying to -

a. open a folder > open latest '.hl7. file (by date) in the folder.

b. search a specific value in the file. e.g value of the key 'name'

c. echo the value.

I am new to scripting, Can anybody help me write a script for the same?

Amit Joshi
  • 15,448
  • 21
  • 77
  • 141
AmitGupta
  • 43
  • 1
  • 6
  • is `hl7` extension or part of the filename? Is the content of hl7 in text format or binary?? – npocmaka Oct 21 '13 at 08:39
  • Yes. The file name ends with '.hl7'. The content of the file is alphanumeric and not binary. see an example http://en.wikipedia.org/wiki/Health_Level_7#HL7_version_2.x – AmitGupta Oct 28 '13 at 10:15

1 Answers1

1

I am not sure about the format of the HL7 files but this will get the most latest HL7 file into env variable MyFile and then print the lines in the file that have "name" in them.

@set MyFile=
@for /F %%I in ('dir /od /b *.hl7') do set MyFile=%%I

@if defined MyFile find "name" %MyFile%

If HL7 has many different formats you may be better off writing a program that uses an HL7 library to parse your file.

I hope this helps you get started.

Okkenator
  • 1,654
  • 1
  • 15
  • 27