SET STEP ON SET EXCLUSIVE ON LOCAL laFiles, lnNoDBFFiles, lnNoCDXFiles, y, x lcDataLoc="c:\your_data_directory" DIMENSION laDBFFiles(1,5) lnNoDBFFiles = ADIR(laDBFFiles,lcDataLoc+"\"+"*.DBF") =ASORT(laDBFFiles,1) DIMENSION laCDXFiles(1,5) lnNoCDXFiles = ADIR(laCDXFiles,lcDataLoc+"\"+"*.CDX") Dimension laFiles(lnNoDBFFiles,6) x=1 For x =1 To lnNoDBFFiles y=1 For y = 1 To 2 laFiles(x,y)=laDBFFiles(x,y) Endfor lnElement = Ascan(laCDXFiles,Juststem(laDBFFiles(x,1))+".CDX") If lnElement>0 laFiles(x,3)=laCDXFiles(lnElement+1) Else laFiles(x,3)=0 Endif Endfor * Pack Files x=1 For x = 1 To lnnodbffiles Wait Window "Packing "+lafiles(x,1)+ " ... Please wait" Nowait Try Use lcdataloc+"\"+(lafiles(x,1)) In 0 Exclusive Pack Use laFiles(x,5)=.T. && Set the array indicating that the file has been Packed CATCH Endtry Wait Clear Endfor * Reindex Files x=1 For x = 1 To lnnodbffiles If lafiles(x,3)>0 && Do only if CDX size > 0 Wait Window "Reindexing "+lafiles(x,1)+ " ... Please wait" Nowait Try Use lcdataloc+"\"+(lafiles(x,1)) Copy Structure To lcdataloc+"\x.dbf" With Cdx Use In (lafiles(x,1)) Copy File lcdataloc+"\x.cdx" To lcdataloc+"\"+Juststem((lafiles(x,1)))+".cdx" Use lcdataloc+"\"+(lafiles(x,1)) In 0 Exclusive Reindex Delete File lcdataloc+"\x.*" laFiles(x,6)=.T. && Set the array indicating that the file has been Reindexed Catch Endtry Use Wait Clear Endif Endfor lnNoCDXFiles = ADIR(laCDXFiles,lcDataLoc+"\"+"*.CDX") x=1 For x =1 To lnNoDBFFiles lnElement = Ascan(laCDXFiles,Juststem(laDBFFiles(x,1))+".CDX") If lnElement>0 laFiles(x,4)=laCDXFiles(lnElement+1) Else laFiles(x,4)=0 Endif Endfor SET EXCLUSIVE OFF>I would like to have a form which re-indexes tables and/or packs then. This is a single user system so I can get the files in EXCLUSIVE mode for the pack command. What I am not sure off is what the best method is to re-index the tables. What is the best way of determining the existing indexes and re-creating them.