Page 1 of 1

Copy files with wild card

Posted: Fri Dec 09, 2005 4:12 pm
by Jeff Barnes
Hi,

I there a way to copy files from within FWH allowing wild cards.

I am tring to do something like:

cFileSource := "F:\Myfile*.*"
cFileDest := "C:\MyFolder\"

Copy File &cFileSource to &cFileDest

but I get a Open error for cFileSource

Thanks,
Jeff

Posted: Fri Dec 09, 2005 4:46 pm
by YamilBracho
Get the files in the source path using Directory, then use an loop or aeval and do the copy, one file at once

Posted: Fri Dec 09, 2005 5:33 pm
by James Bott
I haven't tried it, but this might work.

copyFile(cSource,cTarget,nFailIfExists)

Where nFailIfExists = 0 overwrite if cTarget exists
1 fail if cTarget exists

DLL32 FUNCTION CopyFile( Source_file AS LPSTR, Target_file AS
LPSTR,; Ret_err AS LONG ) AS BOOL FROM "CopyFileA" LIB
"Kernel32.dll"

Posted: Fri Dec 09, 2005 11:01 pm
by Jeff Barnes
Thanks Yamil and James,

James, I tried your soultion but it forced my app to quit (without any error being generated)

Posted: Sat Dec 10, 2005 10:41 pm
by James Bott
Jeff,

Before I gave up I would check to see if it works without a wildcard. It worked for me, but I can't remember, perhaps I only used it in 16bit apps.

James

It works for me

Posted: Sun Dec 11, 2005 3:31 pm
by dutch
Dear Jeff,

This is an example that work for me.

Regards,
Dutch

**********************
aFiles1 = directory("*.db?")
aFiles2 = directory("*.fpt")

if !empty(aFiles1)

aTarget:= {}
aSource:= {}

for n := 1 to len(aFiles1)
aadd(aTarget,DayOfWeek+'\'+aFiles1[n][1])
aadd(aSource,aFiles1[n][1])
next
for n := 1 to len(aFiles2)
aadd(aTarget,DayOfWeek+'\'+aFiles2[n][1])
aadd(aSource,aFiles2[n][1])
next

copyfiles( aSource, aTarget )

endif