Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copying multiple folders

Status
Not open for further replies.

vfpshe

Programmer
Jan 2, 2001
24
0
0
US
Hello,

I need help in copying folders to different network directory. Doing it in windows explorer could have been easy but i need to do it inside my application.

Any idea on what commands to use to copy all folders from a drive to another network drive?

Thanks in advance.
 
if you want to copy all folder from "c:\temp" to "c:\temp2", try this:

run /N xcopy /E /Y "c:\temp\*.*" "c:\temp2"
 
Hi

mySource = GETDIR("*.*","Select Source Directory","")+"*.*"
myDestination = GETDIR("*.*","Select Destination Directory","")
RUN /N XCOPY &mySource &myDestination /S

if you need other xcopy / parameters add them suitably.
Hope this helps :) ramani :)
(Subramanian.G),FoxAcc, ramani_g@yahoo.com
 
Can you hide the ms-dos command prompt while doing the copy? I'm planning to run an animated graphics while the copy is in process.

Thanks for the help.
 
The problem with using Ramani's technique, is that there is no (easy) way to know when it's done, so your big problem isn't hiding the DOS window.

You can use WSH (Windows Script Host) to simplify this task. The following examples were written up by Anders Altberg and "collected" by me.

*:* Copy Directory/Folder
ofs=createobject("scripting.filesystemobject")
ofs.copyfolder('c:\foldername','c:\newfoldername')

*:* Copy Files

* lcfiles is a file name with or without wildcards
* lcdir is the target directory
oShell = CREATEOBJECT('Shell.Application')
oFolder = oShell.Application.Namespace(lcdir)
oFolder.CopyHere(lcfiles)

Additionally, you can specify parameters that control how the dialog operates for example pass FOF_NOCONFIRMATION (0x10) so that a confirmation dialog doesn't appear if a file with the same name exists in the target directory. The constants are mentioned in SHFILEOPSTRUCT topic and the values can be found in Shlobj.h in the VC++ Include sub-directory.

Rick
 
thanks u guys!

u're all geniuses and my heroes...

=)
 
Dear fxshe:

As a compliment to the excelent prior responses, I would like to add this:

A couple of months ago ChrisRChamberlain helped me with a backup application where I needed to copy several files to some other destination. After a lot of working with him, we used the WinExec api call to execute xcopy32 (back in win98) but found that it was almost impossible to determine when the xcopy finished its job. This was specially a problem because I needed to run an xcopy after another, but found no way to determine when the last one finished executing. So, I decided not to use xcopy at all and in the mean time I discovered (chronograph at hand) that there was no noticeable difference in time if I used Vfp6's COPY FILE command instead of xcopy, even when very large files. I also know that xcopy's switches and options are amazing, but at the end, I prefered to not use any D.O.S. commands at all.

I hope that helps.
Rianeiro
 
Another, minor, problem with the dos approach is long filenames for the source/targets. You end up having to put them in quotes. I create a batch file when I need to copy like this, and then run that - it helps with debugging
as well, as you can look at its contents later.

Regards Regards

Griff
Keep [Smile]ing
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top