VBS Script tab not null
Earlier I have made a script to grab certain lines from a tabbed delimited text file, first row with each of the following rows into its own .txt file. (so these .txt files are only 2 rows of text)
Then it would move each .txt file by what text it found in the given tab in this case it was (1)(3) (second row - forth tab)
here is the code for the first part...
Call TwoDimensionArrayTest
Sub TwoDimensionArrayTest
Dim fso
Dim oFile
Dim arrline
Dim arrItem
Dim i
Dim arrMain()
Dim sFileLocation, strResults
Const forReading = 1
strFolder = "\\nas001\Production\RxCut\In Design Implementation\build\" '"
Set objFSO = CreateObject("Scripting.FileSystemObject")
For Each objFile In objFSO.GetFolder(strFolder).Files
If Right(LCase(objFile.Name), 4) = LCase(".txt") Then
''# The file contains on each line:
''# Text1 (tab) Text2 (tab) Text3 (tab) Text4
''# Text5 (tab) Text6 (tab) Text7 (tab) Text8
''# etc etc
Set fso = CreateObject("Scripting.FileSystemObject")
sFileLocation = objFile.Name
Set oFile = fso.OpenTextFile(objFile.Name, forReading, False)
Do While oFile.AtEndOfStream <> True
strResults = oFile.ReadAll
Loop
''# Close the file
oFile.Close
''# Release the object from memory
Set oFile = Nothing
''# Return the contents of the file if not Empty
If Trim(strResults) <> "" Then
''# Create an Array of the Text File
arrline = Split(strResults, vbNewLine)
End If
For i = 0 To UBound(arrline)
If arrline(i) = "" Then
''# checks for a blank line at the end of stream
Exit For
End If
ReDim Preserve arrMain(i)
arrMain(i) = Split(arrline(i), vbTab)
Next
fso.MoveFile sFileLocation, arrMain(1)(3) & ".txt"
End If
Next
End Sub ''# Two开发者_JAVA技巧DimensionArrayTest
Now moving on to the next part...
ok I have a tabbed delimited text file and in this file we have specified on first row 5th tab co-brand, 6th tab tri-brand, and 7th generic.
second row we have the directory path to whichever it maybe either co-brand, tri-brand or generic.
What I want to be able to do is move a given file we can call "group.txt" to either of those co-brand, tri-brand, or generic directories depending upon which field is NOT NULL.
How can I accomplish this? Would be nice to just be able to incorporate this into the last script towards the end where specified:
fso.MoveFile sFileLocation, arrMain(1)(3) & ".txt"
of course would depend from here what I mentioned above about the NOT NULL field.
Any help is greatly appreciated, Joe
my guess is something like this at the end (maybe):
If not isNull(Rs("arrMain(1)(4)")) Then
Set sDirectory = "/co-brand"
End If
If not isNull(Rs("arrMain(1)(5)")) Then
Set sDirectory = "/tri-brand"
End If
If not isNull(Rs("arrMain(1)(6)")) Then
Set sDirectory = "/generic"
End If
fso.MoveFile sFileLocation, sDirectory, arrMain(1)(3) & ".txt"
精彩评论