Help in aqfile.exists(filename)
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-18-2010
02:35 AM
04-18-2010
02:35 AM
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
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-18-2010
03:26 PM
04-18-2010
03:26 PM
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.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-18-2010
09:45 PM
04-18-2010
09:45 PM
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");
}
}
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");
}
}
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-19-2010
04:24 AM
04-19-2010
04:24 AM
Thank you.. I work on vbscript.. will try to convert - hope the methods are available in vbscript as well.... thank you very much...
