We help IT Professionals succeed at work.
Get Started

Java Script (List items in a folder)  - wildcards

Doug Mewmaw
Doug Mewmaw asked
Last Modified: 2012-06-21

Recently, I was given a neat solution to list items in a folder...as 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 customer...so 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

Watch Question
Systems architect
Top Expert 2006
This problem has been solved!
Unlock 4 Answers and 18 Comments.
See Answers
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE