- saveuo.vbs
'
' SAVEUO - Save all user objects of TYPE
' to a given directory (create if doesnt exist)
' Use the preferred name (if duplicate, append a digit)
' -----------------------
' Check usage & arguments
' -----------------------
Set Sout = WScript.StdOut
if WScript.Arguments.Count <> 3 then
Sout.WriteLine "Usage: saveuo <filename> <type> <dirname> "
WScript.Quit
end if
InputFile = WScript.Arguments.Item(0)
UOType = WScript.Arguments.Item(1)
DirName = WScript.Arguments.Item(2)
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
Set UnsniffDB = CreateObject("Unsniff.Database")
UnsniffDB.Open(InputFile)
'
' Check if Directory Exists (Create if it doesnt)
'
If Not fso.FolderExists(DirName) Then
fso.CreateFolder (DirName)
Sout.WriteLine "Created Folder " & DirName
End If
Dim UOIndex
Dim DupFileCount
Set UOIndex = UnsniffDB.UserObjectsIndex
DupFileCount = 0
For Each UO In UOIndex
With UO
If Not .HasError Then
If LCase(.Type) = LCase(UOType) Then
PrefName = .PreferredFileName
If PrefName = "" Then
PrefName = "UnNamedObject.Data"
End If
ExpFilePath = fso.BuildPath (DirName, PrefName )
If fso.FileExists(ExpFilePath) Then
PrefName = "U_" & DupFileCount & "_" & PrefName
ExpFilePath = fso.BuildPath (DirName, PrefName )
DupFileCount = DupFileCount + 1
End If
.SaveToFile(ExpFilePath)
Sout.WriteLine "Saved " & ExpFilePath
End If
End If
End With
Next
UnsniffDB.Close()