Simple Script that needs Improvement (Copy Files)

Author Message
myfairshare

  • Total Posts : 13
  • Scores: 0
  • Reward points : 0
  • Joined: 12/7/2010
  • Status: offline
Simple Script that needs Improvement (Copy Files) Tuesday, January 17, 2012 10:21 PM (permalink)
0
Hi everyone,
I was able to put together a simple script that will copy a file from one location to another. Still learning the Ins and Outs of scripting and perhaps you guys will be able to help me on this one.
 
Here is the script:

Dim Confirm, SourceFolder, TargetFolder

Message = "Cancelled !"
SourceFolder = "C:\TEMP\SOURCE"
TargetFolder = "D:\TEMP\TARGET"

Confirm = MsgBox("Copy Files from C:\ to D:\, would you like to proceed?", vbOKCancel + vbQuestion, "COPY FILES TEST")
if Confirm = vbCancel Then
WScript.Echo Message
WScript.Quit
End If

Set  objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.CopyFolder SourceFolder, TargetFolder
objFSO.DeleteFolder SourceFolder
MsgBox"File Copy Complete!"


 
What I would like to do now is to have a MSGBOX that will appear if the SourceFolder do not Exist.
Then Have an option to Cancel or Try again (Looping the script back at the beginning).
 
Perhaps you could give me an idea, an example that I could work on.
Appreciate your help on this. Thank you in advance.
 
#1
    59cobalt

    • Total Posts : 981
    • Scores: 91
    • Reward points : 0
    • Joined: 7/17/2011
    • Status: offline
    Re:Simple Script that needs Improvement (Copy Files) Tuesday, January 17, 2012 11:47 PM (permalink)
    0
    When in doubt, read the documentation.
     
    #2
      myfairshare

      • Total Posts : 13
      • Scores: 0
      • Reward points : 0
      • Joined: 12/7/2010
      • Status: offline
      Re:Simple Script that needs Improvement (Copy Files) Wednesday, January 18, 2012 8:47 PM (permalink)
      0
      Thank's but I think that link is still to advance for me.
      Appreciate your help on this guys. Thanks again.
       
      #3
        59cobalt

        • Total Posts : 981
        • Scores: 91
        • Reward points : 0
        • Joined: 7/17/2011
        • Status: offline
        Re:Simple Script that needs Improvement (Copy Files) Thursday, January 19, 2012 11:18 AM (permalink)
        0
        If that link is too advanced for you, I'd advise you to start with some basic VBScript tutorial or drop the project altogether. Seriously.
         
        #4
          myfairshare

          • Total Posts : 13
          • Scores: 0
          • Reward points : 0
          • Joined: 12/7/2010
          • Status: offline
          Re:Simple Script that needs Improvement (Copy Files) Thursday, January 19, 2012 11:58 AM (permalink)
          0
          Wow! So much for the help around here huh?
          Thanks anyways Mr. Super Member.
           
          #5
            Wakawaka

            • Total Posts : 456
            • Scores: 23
            • Reward points : 0
            • Joined: 8/27/2009
            • Status: offline
            Re:Simple Script that needs Improvement (Copy Files) Friday, January 20, 2012 3:27 AM (permalink)
            0
            I think 59 is just trying to move you to attempting to learning it and if you have questions about it, then come back and ask about it.

            The linked documentation is for the FolderExists method of the FileSystemObject.  Further down on that page, it actually gives you a function in VBscript that you could use to check if a folder exists.
             
             Set myFSO = CreateObject("Scripting.FileSystemObject)  
             Msgbox myFSO.FolderExists "C:\Program Files\"  
             

            This will return either "True" if the folder exists or "False" if ti doesn't.
            <message edited by Wakawaka on Friday, January 20, 2012 3:29 AM>
             
            #6
              myfairshare

              • Total Posts : 13
              • Scores: 0
              • Reward points : 0
              • Joined: 12/7/2010
              • Status: offline
              Re:Simple Script that needs Improvement (Copy Files) Friday, January 20, 2012 5:16 AM (permalink)
              0
              Thank you sir Wakawaka for your constructive and encouraging help. Will get right to it and try.
              Cheers!
               
              #7

                Online Bookmarks Sharing: Share/Bookmark

                Jump to:

                Current active users

                There are 0 members and 1 guests.

                Icon Legend and Permission

                • New Messages
                • No New Messages
                • Hot Topic w/ New Messages
                • Hot Topic w/o New Messages
                • Locked w/ New Messages
                • Locked w/o New Messages
                • Read Message
                • Post New Thread
                • Reply to message
                • Post New Poll
                • Submit Vote
                • Post reward post
                • Delete my own posts
                • Delete my own threads
                • Rate post

                2000-2012 ASPPlayground.NET Forum Version 3.9