Copy files with wild card

Post Reply
User avatar
Jeff Barnes
Posts: 912
Joined: Sun Oct 09, 2005 1:05 pm
Location: Ontario, Canada
Contact:

Copy files with wild card

Post 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
YamilBracho
Posts: 33
Joined: Mon Oct 17, 2005 11:56 pm
Location: Caracas, Venezuela

Post 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
User avatar
James Bott
Posts: 4654
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA
Contact:

Post 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"
User avatar
Jeff Barnes
Posts: 912
Joined: Sun Oct 09, 2005 1:05 pm
Location: Ontario, Canada
Contact:

Post by Jeff Barnes »

Thanks Yamil and James,

James, I tried your soultion but it forced my app to quit (without any error being generated)
User avatar
James Bott
Posts: 4654
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA
Contact:

Post 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
User avatar
dutch
Posts: 1395
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand

It works for me

Post 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
Post Reply