I am trying to rename a file by using data from a text file's first few lines. It is consistent text file and need to extract bolded text to rename the new file. Following is the initial lines of the text file (text itself is modified, format is same):
----------------------------------
Lutheran Hospital of USA LASTNAME, FIRSTNAME MIDDLE
12345 Washington Blvd. A0000123456
TownName, State 12345 DOB: 01/01/2004
ROOM NUMBER: 123
John Smith, MD
Date of Admission: 09/10/2007
HISTORY AND PHYSICAL
-------------------------------------
My existing file name is just serial number, total 8 character long with .txt extension (00000012.txt)
I like to rename using above bold items following way.
LHN LASTNAME FIRST NAME 01-01-2004 H&P 09-10-2007.TXT
Any help is appreciated.
Thank you.
Jay.
Extracting Text from txt file
Extracting Text from txt file
Hm-m...
I think you want a very smart task. It's possible to write basic script which will analyze text contents and will generate a filename.
But I can't understand how yoy want to conwert string
"Lutheran Hospital of USA" to "LHN"
and
"HISTORY AND PHYSICAL" to "H&P"
I don't know all variants of these strings in order to create universal algorithm.
Also I'm afraid that when the format of file will changed (by some reason) this script will stop working.
I think you want a very smart task. It's possible to write basic script which will analyze text contents and will generate a filename.
But I can't understand how yoy want to conwert string
"Lutheran Hospital of USA" to "LHN"
and
"HISTORY AND PHYSICAL" to "H&P"
I don't know all variants of these strings in order to create universal algorithm.
Also I'm afraid that when the format of file will changed (by some reason) this script will stop working.
Extracting Text from txt file
Thanks for looking into this.
1) Lutheran Hospital >> Don't worry about this, ignore this part.
2) "HISTORY AND PHYSICAL" to "H&P" >> This line has fixed words. They are 1) HISTORY AND PHYSICAL (H&P) 2) CONSULTATION (CONSULT) 3) DISCHARGE SUMMARY (DC).
You can use the letters in parenthesis for that particular phrase. If the phrase is anything other than above than use (MEDSUM).
I realize it that if file changes than script will not work. This file format has been in place for long time and so I am not expecting it to change in near future.
Please give a try.
Thank you.
1) Lutheran Hospital >> Don't worry about this, ignore this part.
2) "HISTORY AND PHYSICAL" to "H&P" >> This line has fixed words. They are 1) HISTORY AND PHYSICAL (H&P) 2) CONSULTATION (CONSULT) 3) DISCHARGE SUMMARY (DC).
You can use the letters in parenthesis for that particular phrase. If the phrase is anything other than above than use (MEDSUM).
I realize it that if file changes than script will not work. This file format has been in place for long time and so I am not expecting it to change in near future.
Please give a try.
Thank you.