I want to execute a file copy,  using vbscript and have builtin validation of the file copy.

Posted on 2007-08-08
Last Modified: 2008-01-09
How can this be done ?
I want the script to check whether it has copied a certain directory and then delete it.
Question by:itbabe
    LVL 17

    Accepted Solution

    Generally, the file will copy fine, or create an Err Code.  For instance, if the network connection goes down in the middle, the script will throw an error, but if it's REALLY important, you can MD5 checksum both files before deleting it:

    Copy A File:
    Const OverwriteExisting = TRUE

    Set objFSO = CreateObject("Scripting.FileSystemObject")
    objFSO.CopyFile "C:\FSO\ScriptLog.txt" , "D:\Archive\", OverwriteExisting

    Move A File (Copy/Delete)

    Const OverwriteExisting = TRUE

    Set objFSO = CreateObject("Scripting.FileSystemObject")
    objFSO.CopyFile "C:\FSO\ScriptLog.txt" , "D:\Archive\", OverwriteExisting

    If err.Number = 0 Then
      WScript.Echo "There was an error: " & err.Description
    End If
    LVL 40

    Expert Comment

    You could also use the DOS COPY command with the /V parameter.

    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    Join & Write a Comment

    This article will show, step by step, how to integrate R code into a R Sweave document
    Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
    Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
    In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now