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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How To Convert Multiple Tables To Text Files In Batch

Status
Not open for further replies.

edrossi

Programmer
Jan 24, 2002
42
US
I am trying to convert hundreds of tables to text and would like to avoid exporting each one. Is there any way to do this in batch? The files exist in the same folder and need to be named exactly what the dbase table name is with the exception of the txt extension, of course.
 
Use ADIR() or SYS(2000) to loop through the files in the directory, and assuming none have Memo fields, you could just use the EXPORT or COPY TO command to create the type of TXT file you want - there are a number of options. Check into to the FORCEEXT() function to change the file name from .DBF to .TXT.

Rick
 
What would the code look like to get the files into an array?
 
Here's a sample, you can tweak it to your needs:

Code:
nHowMany = ADIR(aFileList, "*.DBF")
IF nHowMany < 1
   WAIT WINDOW 'No files to copy' TIMEOUT 3
ENDIF

FOR i = 1 TO nHowMany
   STORE JUSTSTEM(aFileList[i, 1]) + '.TXT' TO cTxtFileName
   USE (aFileList[i, 1]) 
   COPY TO (cTxtFileName) SDF
NEXT
Dave S.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top