Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help converting VB to VbScript

Status
Not open for further replies.

M626

Programmer
Mar 13, 2002
299
Can anyone help with converting this to vbscrit?

Sub DeleteNotInList()
Dim fso As FileSystemObject
Dim dict As Dictionary
Dim InStream As TextStream
Dim InputData As String
Dim fso_folder As Folder
Dim fso_file As File
Dim Dfile As String

Set fso = New FileSystemObject
Set dict = New Dictionary

Set InStream = fso_OpenTextFile("C:\temp\filelist.txt", ForReading)

Do
InputData = InStream.ReadLine
dict.Add InputData, InputData
Loop Until InStream.AtEndOfStream

Set fso_folder = fso.GetFolder("Z:\flvtemp")


For Each fso_file In fso_folder.Files
Dfile = CreateObject("Scripting.FileSystemObject").GetBaseName(fso_file)
If dict.Exists(Dfile & ".flv") = False Then fso.DeleteFile (fso_file), True
Next fso_file


Set fso_folder = Nothing
Set fso_file = Nothing
dict.RemoveAll
Set dict = Nothing
InStream.Close
Set InStream = Nothing
Set fso = Nothing
End Sub
 
Get rid of all the As xxx in the dim lines.
Remove fso_file in the Next line.

Not a conversion issue, but better coding, replace this:
Dfile = CreateObject("Scripting.FileSystemObject").GetBaseName(fso_file)
with this:
Dfile = fso.GetBaseName(fso_file)

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
You also need to change
Code:
Set fso = New FileSystemObject
Set dict = New Dictionary
to
Code:
set fso = CreateObject("Scripting.FileSystemObject")
set dict = CreateObject ("Scripting.Dictionary")
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top