Here's the code I've written....
The copy command (lcnewfile) doesn't work though. I want to actually get the date to print first ie:06282007_importfiles.csv, but I just can't get it to work for me.
*** Premier File Import, Data Work, and Export Program
*** Created by Emboughey
*** 06/28/2007
*** This program imports multiple files with different structures into separate databases
*** This program then combines them into one file, performs data work for back end reporting
*** and exports the data to a file to be sorted for the best postal discounts
*** Standard commands during foxpro program
CLOSE ALL
clear
SET TALK OFF
SET SAFETY OFF
lcprefix = "\\Lettershop\SharedDocs\DP\#DAYTONA-NEW\"
*** Asks for the directory that files are to be imported from
@ 5,5 say 'Enter Directory to import files from: '
thedir = GETDIR()
*** This section imports multiple files to the different table structures provided by client.
USE east-cent.dbf
ZAP
lcPathAndMask = thedir+"*live.xls"
lcFile = Sys(2000, lcPathAndMask)
Do While !Empty(lcFile)
APPEND FROM (lcFile) DELIMITED WITH tab
replace filename WITH (lcfile)for EMPTY(filename)
lcFile = Sys(2000, lcPathAndMask, 1)
USE dr-files
zap
lcPathAndMask = thedir+"dr*.csv"
lcFile = Sys(2000, lcPathAndMask)
Do While !Empty(lcFile)
APPEND FROM (lcFile) DELIMITED
replace filename WITH (lcfile)for EMPTY(filename)
lcFile = Sys(2000, lcPathAndMask, 1)
USE newleads
zap
lcPathAndMask = thedir+"new leads.xls"
lcFile = Sys(2000, lcPathAndMask)
Do While !Empty(lcFile)
APPEND FROM (lcFile) XLS
replace filename WITH (lcfile)for EMPTY(filename)
lcFile = Sys(2000, lcPathAndMask, 1)
USE resends
zap
lcPathAndMask = thedir+"resend*.xls"
lcFile = Sys(2000, lcPathAndMask)
Do While !Empty(lcFile)
APPEND FROM (lcFile) XLS
replace filename WITH (lcfile)for EMPTY(filename)
lcFile = Sys(2000, lcPathAndMask, 1)
USE brown
zap
lcPathAndMask = thedir+"brown*.xls"
lcFile = Sys(2000, lcPathAndMask)
Do While !Empty(lcFile)
APPEND FROM (lcFile) XLS
replace filename WITH (lcfile)for EMPTY(filename)
lcFile = Sys(2000, lcPathAndMask, 1)
USE canada
zap
lcPathAndMask = thedir+"can*.csv"
lcFile = Sys(2000, lcPathAndMask)
Do While !Empty(lcFile)
APPEND FROM (lcFile) DELIMITED
replace filename WITH (lcfile)for EMPTY(filename)
lcFile = Sys(2000, lcPathAndMask, 1)
ENDDO
ENDDO
ENDDO
ENDDO
ENDDO
ENDDO
SET TALK ON
CLOSE ALL
CLEAR
*** Import data from all files into main file for export
USE PREMIER-IN
ZAP
APPEND FROM east-cent
APPEND FROM dr-files
APPEND FROM brown
APPEND FROM newleads
APPEND FROM resends
APPEND FROM canada
*** Datawork. Clean up fields and update for reporting later***
DELETE FOR EMPTY(first) AND EMPTY(last)
REPLACE ALL DPDATE WITH DTOC(DATE())
REPLACE ALL FILENAME WITH UPPER(FILENAME)
REPLACE ALL ORIGIN WITH FILENAME
PACK
*** Updates filename for reporting purposes
repL all filename with 'NY' FOR LEFT(FILENAME,4) = 'DRNY'
repL all filename with 'FL' FOR LEFT(FILENAME,4) = 'DRFL'
REPLACE ALL FILENAME WITH 'CENTRAL' FOR 'PREMCENT'$FILENAME
REPLACE ALL FILENAME WITH 'BROWN' FOR 'BROWN'$FILENAME
REPLACE ALL FILENAME WITH 'EAST' FOR 'PREMEAST'$FILENAME
REPLACE ALL FILENAME WITH 'NEW LEADS' FOR 'NEW LEADS'$FILENAME
REPLACE ALL FILENAME WITH 'RESENDS' FOR 'RESEND'$FILENAME
REPLACE ALL FILENAME WITH 'EAST' FOR 'SERVICE CARD'$FILENAME
*** Updates the table with 'EAST' or 'CENT' depending on filename (state for New Leads and Resends)
REPLACE ALL CENTEAST WITH 'EAST' FOR FILENAME = 'NY'
REPLACE ALL CENTEAST WITH 'EAST' FOR FILENAME = 'NY WEB'
REPLACE ALL CENTEAST WITH 'CENT' FOR FILENAME = 'CENTRAL'
REPLACE ALL CENTEAST WITH 'EAST' FOR FILENAME = 'EAST'
REPLACE ALL CENTEAST WITH 'EAST' FOR FILENAME = 'BROWN'
REPLACE ALL CENTEAST WITH 'EAST' FOR FILENAME = 'FL'
REPLACE ALL CENTEAST WITH 'CENT' FOR FILENAME = 'BROWN'
REPLACE ALL CENTEAST WITH 'CENT' FOR FILENAME = 'FL'
REPLACE ALL CENTEAST WITH 'CENT' FOR 'RESEND'$FILENAME
a="CT-NH-NJ-NY-MI-RI-VT"
REPLACE ALL CENTEAST WITH 'EAST' FOR FILENAME = 'NEW LEADS' AND STATE$A
REPLACE ALL CENTEAST WITH 'CENT' FOR FILENAME = 'NEW LEADS' AND EMPTY(CENTEAST)
REPLACE ALL CENTEAST WITH 'EAST' FOR FILENAME = 'RESENDS' AND STATE$A
REPLACE ALL CENTEAST WITH 'CENT' FOR FILENAME = 'RESENDS' AND EMPTY(CENTEAST)
*** Appends the job number and Week/Drop (WK26-DP5)
CLIST_NO = SPACE (10)
CMAILDATE = SPACE (15)
@ 11,5 say 'Enter Job Number: ' get CLIST_NO
@ 15,5 say 'Enter Week and Drop: ' get CMAILDATE
READ
repl all list_no with alltrim(Clist_no)
REPLACE ALL WKDROP WITH ALLTRIM(CMAILDATE)
*** exports the merged, clean data to a file for import into BCC and presort.
lcnewfile = lcprefix+ALLTRIM(dpdate)+"importfiles.csv"
COPY TO (lcnewfile)csv
SET SAFETY on
SET TALK on
CLOSE ALL
CLEAR