troubleshooting Question

Java Script (List items in a folder) - wildcards

Avatar of Doug Mewmaw
Doug MewmawFlag for United States of America asked on
18 Comments4 Solutions577 ViewsLast Modified:

Recently, I was given a neat solution to list items in a I'm implementing the solution, I discovered I need to change the solution slightly.   I'm betting it’s an easy solution.

Today, I can list items in a folder:

and so on

in the code, this is what made it happen:

  var FilePatern = /MPG.+Rpt\.htm/i;

In my real life situation, the MPG might change to ABC, XYZ, depending on the the var statement needs to be altered a bit.  Can one use a wild card so that I can get something like this:


I have the flexibility to change the report name where the unique ID is at the end of the file name, but before I do that I wanted to see if a wildcard can be used


var Fo; // = new ActiveXObject("Scripting.FileSystemObject");
var StrOut = "";
var FilePatern = /MPG.+Rpt\.htm/i;

function FindFile(FOo) {
    var FSo = new Enumerator(FOo.Files);
    for (var i=0 ; !FSo.atEnd(); FSo.moveNext()) {
        if(FSo.item().name.match(FilePatern)) {
                StrOut += 
                    "<tr " + ((i%2) ? "" : "bgcolor=\"#FFFFFF\"") + ">" + 
                    "<td width=\"40%\" class=\"Find\"><a href=\"" + FSo.item().name + "\">" + FSo.item().name + "</a></td>" + 

function Scan() {
    if ((path.value.length > 0) && (Fo.FolderExists(path.value))) {
        StrOut = "<table border=\"0\" width=\"100%\" cellspacing=\"0\">"
        outPut.innerHTML = StrOut + "</table>";
    else alert("Insert Correct Path Address");

function page_load() {
    Fo = new ActiveXObject("Scripting.FileSystemObject");

window.onload = page_load;

Open in new window

Systems architect

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Top Expert 2006

The Distinguished Expert awards are presented to the top veteran and rookie experts to earn the most points in the top 50 topics.

Log in to continue reading
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform for $9.99/mo
View membership options
Unlock 4 Answers and 18 Comments.
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
The Value of Experts Exchange in My Daily IT Life

Experts Exchange (EE) has become my company's go-to resource to get answers. I've used EE to make decisions, solve problems and even save customers. OutagesIO has been a challenging project and... Keep reading >>


Owner of Outages.IO
Phoenix, Arizona, United States
Member Since 2016
Join a full scale community that combines the best parts of other tools into one platform.
Unlock 4 Answers and 18 Comments.
View membership options
“All of life is about relationships, and EE has made a virtual community a real community. It lifts everyone's boat.”
William Peck

Member since 2004