Get a list of specific file patterns in a folder

I need to look at a folder and check for the existence of files with names that have exactly 12.1 or 12.2 characters. For OS X and Linux, I use a shell and find to match “???.??” and then “???.?” and it works fine.

Trying to get a similar result on Windows, I call dir /b/d “???.??”. If I run this in a terminal, it does what’s expected. However, running it in a shell never completes and the app appears to hang.

I Don’t believe that it’s a Shell issue as I execute 8 other Shell calls successfully prior to this command.

Realizing that it probably makes better sense to use folderitems for this, I’m trying to come up with a test on the fi.Item(X) to see if it matches the wildcard patterns above. I expect that using the fi.Item(x).Name and performing a match check will be pretty efficient, but I can’t come up with a comparison test that succeeds.

Does anyone have a recipe for this type of comparison they could share? Or a big bag of Duh to share with me :slight_smile: ?

Dim itemIdx, dirCount as Integer Dim dir, item as FolderItem dir = SpecialFolder.Desktop dirCount = dir.Count For itemIdx = 1 to dirCount item = dir.Item(itemIdx) If item <> nil Then if instr(item.Name,".") > 0 then dim namefields(-1) as string = split(item.name,".") if len(namefields(0)) = 12 and (len(namefields(1)) = 1 or len(namefields(1)) = 2) then ListBox1.addrow item.name end if end if End If Next

Like I said - hit me with a big bag of “Duh!”.

Thanks Michel. That’s what I get for trying to think too hard about the problem :).

The only change is I’ll use Mid to check specifically for the “.” at character 13.