Bryan
This routine copies all the DBF files in the directory specified by the filename passed in to the specified Destination Directory (there is a default in there if no directory is passed):
DO CopyFiles WITH 'comlist.dbf', 'X:\LocCopies'
Save this and run it
********************************************************************
*** Name.....: COPYFILES.PRG
*** Author...: Andy Kramek & Marcia Akins
*** Date.....: 12/26/2008
*** Notice...: Copyright (c) 2008 Tightline Computers, Inc
*** Compiler.: Visual FoxPro 09.00.0000.3504 for Windows
*** Function.: Copies all DBF from one location
*** Returns..: Default
********************************************************************
LPARAMETERS tcFileName, tcDestDir
LOCAL lcOldDir, lcDestPath, lcSceFile, lcScePath, loErr, lnFiles, lnCnt, lcCurSce, lcDestFile
TRY
*** Save current directory
lcOldDir = FULLPATH( CURDIR())
*** Set the destination path (default if not passed)
lcDestPath = IIF( VARTYPE( tcDestDir ) <> "C" OR EMPTY( tcDestDir ), 'E:\Temp', tcDestDir )
*** These define the source file
IF FILE( tcFileName )
lcSceFile = FULLPATH( LOCFILE( tcFileName, 'dbf' ))
ELSE
ERROR 'Source File Not found'
ENDIF
*** Get the file path and alias name from the file name
lcScePath = JUSTPATH( lcSceFile )
lcSceAlias = JUSTSTEM( lcSceFile )
*** And change to the directory
SET DEFAULT TO ( lcScePath )
*** Now get all the files into an array
lnFiles = ADIR( laFiles, '*.dbf' )
FOR lnCnt = 1 to lnFiles
*** Get the file name
lcCurSce = laFiles[ lnCnt, 1]
IF LEFT( lcCurSce, 1) = "."
*** Ignore directories
LOOP
ENDIF
WAIT WINDOW "Copying Table: " + lcCurSce NOWAIT
*** Open the file for copy
USE (lcCurSce) SHARED NOUPDATE
*** Set the destination name
lcDestFile = ALIAS() + "_cc"
*** Copy to rermote destination
COPY TO ( ADDBS( lcDestPath ) + FORCEEXT( lcDestFile, 'dbf') ) PRODUCTION
NEXT
*** Tidy up
CLOSE TABLES ALL
CATCH TO loErr
MESSAGEBOX( loErr.Message + CHR(13) + CHR(10) + loErr.LineContents, 16, 'File Copy Error' )
FINALLY
*** Restore Working Directory
SET DEFAULT TO (lcOldDir)
ENDTRY
Regards
Andy Kramek
Microsoft MVP (Visual FoxPro)
Tightline Computers Inc, Akron Ohio, USA