Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

help with windows vbscript code

  • 27-04-2004 11:56am
    #1
    Closed Accounts Posts: 333 ✭✭


    I have written a small script that copies a file (or number of files) from a folder to two different locations and then deletes the original. The problem is that it works fine when I hardcode in the actual filename, but it will not work when I try to use a wildcard filename (e.g. "*.pdf"). I need to use the wildcard because at runtime, I will not know the filename because they are randomly generated. Any ideas??

    ' VBScript.
    Dim FSO
    Set FSO = CreateObject("Scripting.FileSystemObject")

    ' make sure the files exist before copying them
    if FSO.FileExists("*.pdf") then
    FSO.CopyFile "*.pdf", "FolderA"
    FSO.CopyFile "*.pdf", "FolderB"
    end if

    ' make sure the files exist before deleting them
    if FSO.FileExists("*.pdf") then
    FSO.DeleteFile "*.pdf"
    end if

    ' destroy object
    set FSO = nothing


    If I substitute an actual filename (e.g. "Sample1.pdf") for ("*.pdf") in the above code, it works fine.


Comments

  • Registered Users, Registered Users 2 Posts: 2,781 ✭✭✭amen


    its doesn't work because you are looking for a file called
    *.pdf
    you need to have some way to search the directory structure checking if the file is pdf and then what you need to


  • Closed Accounts Posts: 333 ✭✭McGintyMcGoo


    Cant believe I have been so stupid!
    I wrote a 3 line batch file and set that to run in scheduler!

    Thanks anyway!


Advertisement