Re: file copier with log
- From: "Pegasus \(MVP\)" <I.can@xxxxxxxxxx>
- Date: Mon, 9 Jun 2008 17:35:06 +0200
"krazymike" <krazymike@xxxxxxxxx> wrote in message
news:599d4797-31cf-4449-9726-b6ded48082a5@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
I'm writing a file copier where the user chooses the source directory
and the destination directory. I'm trying to preserve the file
structure, too. The dest is usually going to be a network path, so I
map a drive to it to avoid the MAX_PATH limit. I still have to re-map
this drive "on-the-fly" because the source's path gets pretty long,
too.
My procedure is recursive "for each file in folder.files . . . and
for each fldr in folder.subfolders recall procedure."
A colleague suggested that i map the source directory, too, and map
"on-the-fly." I think this would throw off my recursion. Also, I
need to log in an .mdb the source path, destination path, drive
mapping paths, and a verification that the copy was successful. I
have the logging part done and the destination mapping (not shown), i
just need help with the source mapping not throwing off my recursion.
Sub main()
Set rs = CurrentDb.OpenRecordset("Filecopy")
i = 0
Set fso = New FileSystemObject
Set srcF = fso.GetFolder(Prod_Path)
Set destF = fso.GetFolder(Prod_Path)
Call xerox(srcF)
End Sub
Sub xerox(f As folder)
Dim x As File, y As folder
For Each x In f.Files
i = i + 1
filecopier(x, f)
Next
For Each y In f.SubFolders
Call xerox(y)
Next
End Sub
Seeing that this particular wheel has been inventend and fully
optimised a long time ago at the Command Line level, I would
use the Run method of the WScript.Shell object to invoke
xcopy.exe or robocopy.exe. It handles all the recursive stuff
fully automatically and requires just one single line of code, e.g.
robocopy /s "d:\User Files" "\\TargetServer\Share\Folder" *.*
It even has inbuilt error handling routines.
BTW, what do you mean with " I'm trying to preserve the file
structure, too"? I thought that if a process does not preserve
the file structure then it's not a copy process?
.
- References:
- file copier with log
- From: krazymike
- file copier with log
- Prev by Date: Re: help - batch copy /b command for vbs
- Next by Date: reading coma seperated text file error
- Previous by thread: file copier with log
- Next by thread: reading coma seperated text file error
- Index(es):
Relevant Pages
|