|
Karen, If you are sure that there will only be one file per part number, and if the part numbers are unique, then the first bit of VB code below will search for a file beginning with <PARTNO> and put it into a file. If you also want to extract the revision number, and you know that there will only be numbers between the final R (regardless of how many Rs there are in the part number itself) and the . in the file name (there there will be only on period in the file name), then the second code sample below will output a single line to a CSV file with the full file name,revision number. _vbscript_ 1 On Error Resume Next Dim fso,folder,files,NewFile,sPartNo,sCurFName,iPartNoLen Set fso = CreateObject("Scripting.FileSystemObject") sPartNo = Wscript.Arguments.Item(0) If sPartNo = "" Then Wscript.Echo "No sPartNo parameter was passed" Wscript.Quit End If Set NewFile = fso.CreateTextFile("FileList.csv", True) Set folder = fso.GetFolder(".") Set files = folder.Files iPartNoLen = Len(sPartNo) For each folderIdx In files sCurFName = folderIdx.Name If Left(sCurFName,iPartNoLen) = sPartNo Then NewFile.WriteLine(sCurFName) End If Next NewFile.Close _vbscript_ 2 On Error Resume Next Dim fso,folder,files,NewFile,sPartNo,sCurFName,iPartNoLen Dim iStartPos,iEndPos,iRlen Dim sRVal Set fso = CreateObject("Scripting.FileSystemObject") sPartNo = Wscript.Arguments.Item(0) If sPartNo = "" Then Wscript.Echo "No sPartNo parameter was passed" Wscript.Quit End If Set NewFile = fso.CreateTextFile("FileList.csv", True) Set folder = fso.GetFolder(".") Set files = folder.Files iPartNoLen = Len(sPartNo) For each folderIdx In files sCurFName = folderIdx.Name If Left(sCurFName,iPartNoLen) = sPartNo Then sCurFName = UCase(sCurFName) iEndPos = InStr(1,sCurFName,".",0) - 1 iStartPos = InStrRev(sCurFName,"R",iEndPos,0) + 1 iRLen = iendPos-iStartPos + 1 sRVal = Mid(sCurFName,iStartPos,iRlen) NewFile.WriteLine(sCurFName & "," & sRVal) End If Next NewFile.Close Jason Kramer University Archives and Records Management 002 Pearson Hall (302) 831 - 3127 (voice) (302) 831 - 6903 (fax) On 2/9/2011 4:57 PM, [email protected] wrote: Jason: I'll certainly look over your vb code in detail later! Love analyzing vb code. |
- [RBASE-L] - Re: Getting a file from a directory KarenTellef
- [RBASE-L] - Re: Getting a file from a directory Lawrence Lustig
- [RBASE-L] - Re: Getting a file from a directory A. Razzak Memon
- [RBASE-L] - Re: Getting a file from a directory KarenTellef
- [RBASE-L] - Re: Getting a file from a directory Jim Belisle
- [RBASE-L] - Re: Getting a file from a directory KarenTellef
- [RBASE-L] - Re: Getting a file from a directory Jim Belisle
- [RBASE-L] - Re: Getting a file from a directory Jason Kramer
- [RBASE-L] - Re: Getting a file from a directory KarenTellef
- [RBASE-L] - Re: Getting a file from a directory Bernard Lis
- [RBASE-L] - Re: Getting a file from a directory Jason Kramer
- [RBASE-L] - Re: Getting a file from a directory KarenTellef
- [RBASE-L] - Re: Getting a file from a directory Mike Byerley
- [RBASE-L] - Re: Getting a file from a directory Emmitt Dove

