cancel
Showing results for 
Search instead for 
Did you mean: 

Help in aqfile.exists(filename)

Highlighted
Contributor

Help in aqfile.exists(filename)

my file name is created with a pattern like _fname_lname_hrs_minutes_secs.extn

I have to verify the file if its is created or not.  I need to ignore the secs.  Is there a way to include regexpr or check part of the filename is satisfied or not. 


If regular expresssion can be used, please give me the code for verification it has two digits for secs.

3 REPLIES 3
Highlighted
Contributor

RE: Help in aqfile.exists(filename)

I'm pretty sure that the aqFile.Exists method is not going to help you with that. What you could do instead is use aqFileSystem.FindFiles, which takes a pattern and returns all the files that match it.
Highlighted
Occasional Contributor

RE: Help in aqfile.exists(filename)

Try something like this:



JScript:



function FileCheck()

{

  var regEx = /_fname_lname_[0-9]{2}_[0-9]{2}_[0-9]{2}.extn/ig;

  var folder = "C:\\";

  var fileString = "";

  var hoursMins = aqDateTime.GetHours(aqDateTime.Now()) + "_"

    + aqDateTime.GetMinutes(aqDateTime.Now());

  var matchFound = false;

 

  var files = aqFileSystem.GetFolderInfo(folder).Files;

 

  for (var i = 0; i < files.Count; i++)

  {

    fileString += files.Item(i).Name + "\r\n";

  }

 

  // Perform search operation

  var matches = fileString.match(regEx);

 

  if (matches != null)

  {

    // Iterate through Matches array

    for (var i = 0; i < matches.length; i++)

    {

      if (aqString.Contains(matches, hoursMins, 0, false) > -1)

      {

        Log["Message"]("These files matched: " + matches);

        matchFound = true;

      }

    }

  }

 

  if (!matchFound)

  {

    Log.Message("No matches");

  }

}
Highlighted
Contributor

RE: Help in aqfile.exists(filename)

Thank you.. I work on vbscript.. will try to convert - hope the methods are available in vbscript as well.... thank you very much...
New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors