VBscript with multiple functions

Home Forums Scripting General Scripting VBscript with multiple functions

This topic contains 0 replies, has 1 voice, and was last updated by Avatar hilsoe 3 years, 3 months ago.

Viewing 1 post (of 1 total)
  • Author
    Posts
  • Avatar
    hilsoe
    Participant
    #166144

    I have created a script to look for the newest file in a folder, check if the file exists and delete it if it does and then at last copy it.

    dim filesys
    dim filesystem
    Set filesys=CreateObject(“Scripting.FileSystemObject”)
    set filesystem=CreateObject(“Scripting.FileSystemObject”)
    set oFolder=createobject(“scripting.filesystemobject”).getfolder(“C:my path”)
    For Each aFile In oFolder.Files
    If sNewest = “” Then
    Set fNewest = aFile
    sNewest = aFile.Name
    Else
    If fNewest.DateCreated < aFile.DateCreated Then Set fNewest = aFile End If End If Next filesys.CreateTextFile "X:my path" & fNewest.Name , True If filesys.FileExists("X:my path" &fNewest.Name ) Then filesys.DeleteFile "X:my path" &fNewest.Name End If If filesystem.FileExists("C:my path" & fNewest.Name) Then filesystem.CopyFile "C:my path" & fNewest.Name, "X:my path" End if [/CODE] I would like to change the script so it merges the new copied file with the one existing in the destination folder. I'm having a little trouble figuring out how to merge files in vbs.[CODE]
    dim filesys
    dim filesystem
    Set filesys=CreateObject(“Scripting.FileSystemObject”)
    set filesystem=CreateObject(“Scripting.FileSystemObject”)
    set oFolder=createobject(“scripting.filesystemobject”).getfolder(“C:my path”)
    For Each aFile In oFolder.Files
    If sNewest = “” Then
    Set fNewest = aFile
    sNewest = aFile.Name
    Else
    If fNewest.DateCreated < aFile.DateCreated Then
    Set fNewest = aFile
    End If
    End If
    Next

    filesys.CreateTextFile “X:my path” & fNewest.Name , True
    If filesys.FileExists(“X:my path” &fNewest.Name ) Then
    filesys.DeleteFile “X:my path” &fNewest.Name
    End If

    If filesystem.FileExists(“C:my path” & fNewest.Name) Then
    filesystem.CopyFile “C:my path” & fNewest.Name, “X:my path”
    End if
    [/CODE]

    I would like to change the script so it merges the new copied file with the one existing in the destination folder. I’m having a little trouble figuring out how to merge files in vbs.

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.