>>I have a master directory that has many subdirectories. Each subdirectory has a codes.dbf file and a bankcntl.dbf. I want to combine all the codes.dbf files in the master directory. But .... I also need the bankcntl.siteID field added to the resulting combined table. The bankcntl table has a single record, and the siteID value is different in each subdirectory.
>
>The following untested code should get you started .
lcMainFolder = ADDBS("...")
>* Codes table in the main directory
>USE (lcMainFolder + "mainCodes") Exclusive
>ZAP
>
>FOR i=1 TO ADIR(laFolders, lcMainFolder + "*.","D")
> IF NOT ("D" laFolders[i,5])
> LOOP
> ENDIF
> USE IN ( SELECT("Codes") )
> USE IN ( SELECT("bankcntl") )
> lcFolder = ADDBS(lcMainFolder + laFolders[i,1])
> USE (lcFolder + "Codes") IN 0
> USE (lcFolder + "bankcntl") IN 0
> SELECT Codes.*, bankcntl.siteID ;
> FROM Codes, bankcntl ;
> INTO CURSOR crsTemp
> SELECT mainCodes
> APPEND FROM ( DBF("crsTemp") )
> USE IN crsTemp
>ENDFOR
>
IN VFP8 and later you can use INSERT INTO...SELECT FROM to make code shorter.
I have two questions and one problem.
The ADIR below always returns '.' for laFolders[1,1] and '..' for Folders[2,1] - why is that? Because of it I have my loop FOR i=3 to .......
What does the '*.*' do for me when asking for directories. I had a directory called 'before.after' and it is not being picked up by the ADIR. If I remove the '.' it is picked up.
I need to be able to traverse down the folder structure. My codes.dbf and bankcntl.dbf may be several folders below the lcMainFolder.
FOR i=1 TO ADIR(laFolders, lcMainFolder + "*.","D")