Option Explicit 'force all variables to be declared ' ' intent for this script is to pack all unity .meta files into one directory that can be zipped ' and transferred as a single file rather than 1000s of tiny files between every other file. ' ' simply place in project folder next to Assets, run packmeta.vbs and ensure no interrupt. ' verify content of metapack.txt (db) and files in metapack\, and creation of metapack.lock. ' ' zip metapack and metapack.txt, bring with the .lock and .vbs scripts etc within or not~. ' delete the non-zipped metapack\ directory and transfer the project folder with the zip. ' ' on new destionation, do Not run packmeta, .lock will prevent it as well if brought (required) ' but do 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. ' ' This script was made by Twily/Analie Oct 2025 ' This script is the packmeta.vbs ' Const ForReading = 1 Const ForWriting = 2 Dim FSO Set FSO = CreateObject("Scripting.FileSystemObject") Dim objTS 'Text Stream Object Set objTS = FSO.OpenTextFile("metapack.txt", ForWriting, True) 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 Recurse FSO.GetFolder("test\") objTS.Close() ' 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 >= 2 Then 'Wscript.Echo lineC & "] hashed: " & "metapack\" + arrServiceList(0) & ".meta" For i = 1 to Ubound(arrServiceList) 'Wscript.Echo "real: " & arrServiceList(i) FSO.DeleteFile(arrServiceList(i)) 'DELETES ORIGINAL Next End If lineC = lineC + 1 Loop objTS.Close() Sub CreateLockfile Dim objLC Set objLC = FSO.CreateTextFile("metapack.lock", True) objLC.WriteLine("packmeta.vbs has been executed, this file is in place to prevent overwriting/wiping contents of metapack directory, see metapack.txt") objLC.Close End Sub Private Function SHA1(s) Dim asc, enc, bytes, outstr, pos Set asc = CreateObject("System.Text.UTF8Encoding") Set enc = CreateObject("System.Security.Cryptography.SHA1CryptoServiceProvider") 'Convert the string to a byte array and hash it bytes = asc.GetBytes_4(s) 'This is how you use .Net overloaded methods in VBScript bytes = enc.ComputeHash_2((bytes)) outstr = "" 'Convert the byte array to a hex string For pos = 1 To Lenb(bytes) outstr = outstr & LCase(Right("0" & Hex(Ascb(Midb(bytes, pos, 1))), 2)) Next SHA1 = outstr Set asc = Nothing Set enc = Nothing End Function ' initial scan and copy, write db file etc Sub Recurse(objFolder) Dim objFile, objSubFolder If printOnce = 0 Then If (FSO.FileExists("metapack.lock")) Then MsgBox("metapack.lock file exists, exiting sub. delete or unpack first!") stopExec = 1 Exit Sub End If If NOT (FSO.FolderExists("metapack")) Then FSO.CreateFolder("metapack") Else MsgBox("directory metapack already exists, exiting sub. delete or unpack first!") stopExec = 2 Exit Sub End If If Not stopExec = 0 Then Exit Sub CreateLockfile() WorkingPath = FSO.GetAbsolutePathName(".") objTS.WriteLine(WorkingPath + "\") printOnce = 1 lastIndexOfBackSlash = InStrRev(WorkingPath,"\") ProjectName = Mid(WorkingPath,lastIndexOfBackSlash + 1) objTS.WriteLine(ProjectName) End If For Each objFile In objFolder.Files If LCase(FSO.GetExtensionName(objFile.Name)) = "meta" Then CanonicalPath = FSO.GetAbsolutePathName(objFile) RelativePath = Mid(CanonicalPath,Len(WorkingPath) + 2) 'objTS.WriteLine(WorkingPath + " " + CanonicalPath) hashName = SHA1(RelativePath) objTS.WriteLine(hashName + "," + RelativePath) SourceFile = RelativePath DestinationFile = "metapack\" + hashName + ".meta" 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 End If Next For Each objSubFolder In objFolder.SubFolders Recurse objSubFolder Next End Sub