~scriptsvbs
3 itemsDownload ./*

..
onedrivesub.vbs
packmeta.vbs
unpackmeta.vbs


vbsunpackmeta.vbs
4 KB• 6•  20 hours ago•  DownloadRawClose
20 hours ago•  6

{}
Option Explicit 'force all variables to be declared
'
' run unpackmeta.vbs in the same directory next to Assets and metapack with metapack.txt
'
' confirm the metapack directory is emptied after unpack, .lock and .txt is removed.
' all .meta should now be reinstated in the correct directory with correct names.
'
' read more packing instruction in packmeta.vbs.
'
'						This script was made by Twily/Analie Oct 2025
'								This script is the unpackmeta.vbs
'
Const ForReading = 1
Dim FSO
Set FSO = CreateObject("Scripting.FileSystemObject")

Dim objTS 'Text Stream Object

'Dim WorkingPath
'Dim CanonicalPath
'Dim RelativePath
'Dim printOnce
'printOnce = 0
'Dim lastIndexOfBackSlash
'Dim ProjectName
'Dim hashName
Dim stopExec
stopExec = 0
Dim DestinationFile
Dim SourceFile

Dim strNextLine
Dim arrServiceList
Dim i
Dim lineC
lineC = 0

If NOT (FSO.FileExists("metapack.lock")) Then
	MsgBox("metapack.lock file does Not exists, exiting. if metapack\ and metapack.txt exist then create the metapack.lock")
	stopExec = 1
End If
If NOT (FSO.FolderExists("metapack")) Then
	MsgBox("directory metapack\ does Not exists, exiting. forgot unzip metapack?")
	stopExec = 2
End If
If NOT (FSO.FileExists("metapack.txt")) Then
	MsgBox("file metapack.txt does Not exists, exiting. forgot to bring with?")
	stopExec = 3
End If

If stopExec = 0 Then
	' after exec read through db file, deletes real metas (keeping metapack only!)
	Set objTS = FSO.OpenTextFile("metapack.txt", ForReading)
	Do Until objTS.AtEndOfStream
		strNextLine = objTS.Readline
		arrServiceList = Split(strNextLine , ",")
		'If lineC = 0 Then
		'	Wscript.Echo lineC & "] Original pack location: " & arrServiceList(0)
		'Else If lineC = 1 Then
		'	Wscript.Echo lineC & "] Project Name Packed: " & arrServiceList(0)
		'Else 
		If lineC >= 2 Then
			'Wscript.Echo lineC & "] hashed: " & "metapack\" + arrServiceList(0) & ".meta"
			SourceFile = "metapack\" + arrServiceList(0) & ".meta" ' hashName
			
			For i = 1 to Ubound(arrServiceList)
				'Wscript.Echo "real: " & arrServiceList(i)
				DestinationFile = arrServiceList(i)
				
				If FSO.FileExists(DestinationFile) Then
					'Check to see if the file is read-only
					If Not FSO.GetFile(DestinationFile).Attributes And 1 Then 
						'The file exists and is not read-only.  Safe to replace the file.
						FSO.CopyFile SourceFile, DestinationFile, True
					Else 
						'The file exists and is read-only.
						'Remove the read-only attribute
						FSO.GetFile(DestinationFile).Attributes = FSO.GetFile(DestinationFile).Attributes - 1
						'Replace the file
						FSO.CopyFile SourceFile, DestinationFile, True
						'Reapply the read-only attribute
						FSO.GetFile(DestinationFile).Attributes = FSO.GetFile(DestinationFile).Attributes + 1
					End If
				Else
					'The file does not exist in the destination folder.  Safe to copy file to this folder.
					FSO.CopyFile SourceFile, DestinationFile, True
				End If
			Next
		End If
		lineC = lineC + 1
	Loop
	objTS.Close()
	
	Set objTS = FSO.OpenTextFile("metapack.txt", ForReading)
	Do Until objTS.AtEndOfStream
		strNextLine = objTS.Readline
		arrServiceList = Split(strNextLine , ",")
		If lineC >= 2 Then
			' delete all hashed names in metapack\ then the directory here
			If FSO.FileExists("metapack\" + arrServiceList(0) + ".meta") Then
				FSO.DeleteFile("metapack\" + arrServiceList(0) + ".meta") 'DELETES HASHED
			End If
			' then delete metapack.lock and metapack.txt
			'Wscript.Echo lineC & "] hashed: " & "metapack\" + arrServiceList(0) & ".meta"
			'For i = 1 to Ubound(arrServiceList)
			'	Wscript.Echo "real: " & arrServiceList(i)
			'Next
		End If
		lineC = lineC + 1
	Loop
	objTS.Close()
	FSO.DeleteFile("metapack.lock") 'cleanup
	FSO.DeleteFile("metapack.txt")
	FSO.DeleteFolder("metapack")
End If

Top
©twily.info 2013 - 2025
twily at twily dot info



2 471 728 visits
... ^ v