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()
unsniff/samples/saveuo/vbs.txt · Last modified: 2014/09/11 23:23 (external edit)
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki