Results 1 to 3 of 3

Thread: File Name Retrieval

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Aug 2002
    Posts
    24

    Resolved File Name Retrieval

    Hi,

    I need some help on retrieving file names in a specific location, the only problem is the filename is relevant to the machine I am connecting to, so need some sort of wild card option to search for the constant in the file name, and then pull back the full name.

    As an example, if I have a number of machines names computer001 through to computer100, and each machine has a file named computername_status.log (eg computer089_status.log) how can I look for the _status.log part of the filename and then return the complete name to my script?

    It's not a simple as getting the computername as this is an example, the file I'm after is a filename followed by a random 3 figure number.log hence the wild care requirement.

    I hope this is clear in what I am trying to do...

    Thanks.
    Last edited by fireblade; Aug 18th, 2006 at 03:56 AM.

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: File Name Retrieval

    VB Code:
    1. myfile = Dir(path & "*._status.log")

    will return the first file in the path that matches, calling Dir after (ususally in a loop) will get the next etc.
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Aug 2002
    Posts
    24

    Re: File Name Retrieval

    So simple it's genius, thanks...

    Resolved

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width