VB Script to copy and paste folder from network drive

Dear All


            I'm looking for a vbs that can help to copy Folder from one network drive to another location by using task schedule manager, below is the one i found from internet, but only workable for copying files, not a folder, do any one know which vb script that can copy folder as well ? thanks


1
piaakitAsked:
Who is Participating?
 
Michael PfisterConnect With a Mentor Commented:
Why use a VBScript?
Use robocopy

I.e.
Robocopy "\\10.154.101.150\Upload from WP" "\\10.141.101.11\...." /S /NP /R:1 /W:1 /LOG+:Logfile.log

Open in new window


Add /MOVE to move files instead of copying

would copy source to target with subfolders (/S). It will save a log file you can check for problems/errors.
If its unable to copy a file it will retry it once (/R:1) after waiting 1 second (/W:1)
HTH
0
 
Fabrice LambertFabrice LambertCommented:
Hi,

The FSO object provide a MoveFolder member function:
Sub MoveFolder()
    Const source = "c:\........"
    Const target = "c:\..............."

    Dim fso
    Set fso = createObject("Scripting.FileSystemObject")
    fso.MoveFolder source, target
    Set fso = Nothing
End Sub

Open in new window

0
 
piaakitAuthor Commented:
The robocopy can do a move and paste and after the moved it will empty the source files ?
0
 
Michael PfisterCommented:
Robocopy /MOVE will delete each source file after copying it. SImilar to WIndows epxlorer or VBScript MoveFile/MoveFolder
0
 
piaakitAuthor Commented:
the robycopy work well
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.