Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

WORD FILE NAME CONVERSION

Status
Not open for further replies.

FoxEgg

Programmer
Mar 24, 2002
749
0
16
AU
I am converting all my WordPerfect 6.2(for Windows) patient files to Word... There are hundreds of them.

The old filename was limited in the past to 8.3 under DOS and so I used the following encryption.

Example:

John SMITH date of birth 12 November 1933 became

SM331112 (date of Birth in reverse order)

Now, the NEW format for saving as a Word file utilizing long names is going to be

SMITH,JOHN,12 November 1933

much more readable...

I have already converted ALL the WordPerfect Files to Word files (there is a utility in Word for this), so now I have to convert the SM331112 to SMITH,JOHN,12 November 1933.. and needless to say this will be tedious if not done programmatically.

The thought is that I would have to

1. Open the Word directory
2. Get the first occurrence of patient file eg Anne Aardvark 1/1/1985 = AA850101
3 and it should be easy to use substrings to break up the string and ge the date of birth... Uh Oh ! AA does not give me AARDVARK... so that means I need to have to get NAME data from my VFP table

SO FORGET THE ABOVE --->>>>

Change of thought... PLAN 2

So I imagine that the best way is to create a 'tidy' VFP data table with the LASTNAME, FIRSTNAME, DOB and OLD_FILE_NUMBER, and NEW_FILE_NUMBER...

Get Anne Aarvark (or whoever is first) and her file name / date of birth... go to Word processing directory and see if there is an entry for her... (there may be some patients without a letter entries).. If present open it and save it as AARVARK,ANN,01 January 1985... move on to the next one.


Obviously I will need to test the DIrectory with an FOPEN or other (to see if there is an existing Word file present) if so open and save it with a new file name (I want to keep the original) close and move on. It seems that I should not have to OPEN another instance of Word Automation to do this.... I could use dos type commands, or maybe SHELL Execute commands.

I throw this up as my suggested approach... has anyone done anything similar... ?

ALso if anyone knows the best SHELL commands to do the Save As it would be appreciated.


John Fox









 
instead of
"If present open it and save it as AARVARK,ANN,01 January 1985... move on to the next one.
"

RENAME FileName1 TO FileName2

Attitude is Everything
 
Hi John,

Are all the files formatted identically? Could you possibly use FILETOSTR() or the low level file functions FOPEN() etc. to extract the information?

Regards,

Mike
 
HI

The following code has not been tested and written directly here. But the idea should take you thru..

nCount = ADIR(laFiles,'*.DOC')
FOR i=1 TO nCount
lcName = JUSTSTEM(laFiles(i,1))

** Ignore files with length > 8
** incase long names already exist
** IF length < 8 .. not correct format .. ignore
IF LEN(lcName) # 8
LOOP
ENDIF

** Check Short file names
lcName1 = LEFT(lcName,2)
lcName2 = RIGHT(lcName,6)

** Now read master to convert first two char to Name
put code here

** Convert last 6 Char to Long Date format
put code here

** Concoctinate the names

ENDFOR


____________________________________________
ramani - (Subramanian.G) :)
 
HI

I did not complete and by accident pressed post...

After the names are initiated..

lcOldName = laFiles(i,1)
lcNewName = name1+name2+[.Doc]

RENAME &lcOldName TO &lcNewName

:)

____________________________________________
ramani - (Subramanian.G) :)
 
Thanks Dancester, Ramani and Mike,,, sorry for the delay in acknowledging your assistance... (due to a minor medical cataclysm here)

Are all the files formatted identically? Could you possibly use FILETOSTR() or the low level file functions FOPEN() etc. to extract the information?

Yes all were WordPerfect files and are now MS Word files. But I don't need to change the files, only the file names... so the RENAME option is good...

and I think Ramani has hit my problem on the head...

I needed to search for the file and see if it existed...

I will try and find time to play with the Ramani code for a bit... and will report back.

Serious thanks..

John



 
Ramani, I am having some grief with

Code:
nCount = ADIR(laFiles,'*.DOC')


sometime it gives me an error message

Prgoram Error laFiles is not an array..

According to VFP help .. ADIR creates an array... even if it doesn't alrady exist ,,, so it shouldn't error message me

Is there something I am missing here?

Fox Egg
 
Does it give the error on that line, or when you try to use it?

Why not add a check "around" the FOR loop, like:
Code:
IF type("laFiles[1,1]") <> "C"
   FOR ..
      ...
   ENDFOR
ELSE
   * No .DOCs available
ENDIF
Rick
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top