I've been able to string together the basic code for what I want by searching TekTips and other sites. The code below will search a network share for a particular file and write the folder|filename to a text file. What I need is for it to search multiple directories that have a similar structure:
n:\prod\00572\From-Other\YYYYMMDD-Download
n:\prod\00573\From-Other\YYYYMMDD-Download
n:\prod\00574\From-Other\YYYYMMDD-Download
...
...and I need for it to search not for a specific file but for any file that contains "OP." prior to the extension (the extension is incremental numeric). So my output text file should look something like this:
n:\prod\00572\From-Other\YYYYMMDD-Download|CR13OP.001
n:\prod\00572\From-Other\YYYYMMDD-Download|CR13OP.002
n:\prod\00572\From-Other\YYYYMMDD-Download|CITNOP.001
n:\prod\00573\From-Other\YYYYMMDD-Download|CR13OP.001
n:\prod\00574\From-Other\YYYYMMDD-Download|YUITOP.001
Help is appreciated!
n:\prod\00572\From-Other\YYYYMMDD-Download
n:\prod\00573\From-Other\YYYYMMDD-Download
n:\prod\00574\From-Other\YYYYMMDD-Download
...
...and I need for it to search not for a specific file but for any file that contains "OP." prior to the extension (the extension is incremental numeric). So my output text file should look something like this:
n:\prod\00572\From-Other\YYYYMMDD-Download|CR13OP.001
n:\prod\00572\From-Other\YYYYMMDD-Download|CR13OP.002
n:\prod\00572\From-Other\YYYYMMDD-Download|CITNOP.001
n:\prod\00573\From-Other\YYYYMMDD-Download|CR13OP.001
n:\prod\00574\From-Other\YYYYMMDD-Download|YUITOP.001
Help is appreciated!
Code:
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set objFSO = CreateObject("Scripting.FileSystemObject")
strFolderName = "n:\prod\00572\From-Other\" & Year(Date) & Right("0" & Month(Date),2) & Right("0" & Day(Date),2) & "-Download"
'strFileName = strFolderName & "\" & "CR13OP.001"
strFileName = strFolderName & "\" & objFSO.GetExtensionName()
If objFSO.FileExists(strFileName) Then
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.CreateTextFile("C:\prod\Test.txt")
objTextFile.Writeline objFSO.GetFolder(strFolderName) & "|" & objFSO.GetFileName(strFileName)