Moving Files with VB Script

Posted on 2011-10-10
Last Modified: 2012-05-12

I want to move files between directories within a small vb script.
If I specify the directory and filename the move works fine, but not when I try to use variables.

        Set objFSO = CreateObject("Scripting.FileSystemObject")
        Set TransferFile = objFSO.GetFile(strFullFilePath)
        objFSO.MoveFile "C:\Program Files\Bitvise Tunnelier\update091011.txt", "c:\NewLocation\"

This works, but when I use the following it fails :-

          objFSO.MoveFile "TransferFile", "c:\IVR\"

No error message the file is just not copied.
Question by:HRMorton
    LVL 39

    Expert Comment

    by:Pratima Pharande
    remove "

    objFSO.MoveFile  TransferFile, "c:\IVR\"
    LVL 39

    Accepted Solution

     Set objFSO = CreateObject("Scripting.FileSystemObject")
            Set TransferFile = objFSO.GetFile(strFullFilePath)
            objFSO.MoveFile TransferFile, "c:\IVR\"

    Author Closing Comment

    So simple, but worked perfectly.
    Thanks for the help.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    I remember the day when someone asked me to create a user for an application developement. The user should be able to create views and materialized views and, so, I used the following syntax: (CODE) This way, I guessed, I would ensure that use…
    Configuring and using Oracle Database Gateway for ODBC Introduction First, a brief summary of what a Database Gateway is.  A Gateway is a set of driver agents and configurations that allow an Oracle database to communicate with other platforms…
    This video explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.
    This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

    754 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

    24 Experts available now in Live!

    Get 1:1 Help Now