'---------------------------------------------------------------------------' ' 1. This simple VBScript program Extract.vbs is developed by ' ' Geodetic Survey Section, Lands Department of Hong Kong SAR Government. ' ' 2. Rename this file Extract.txt as Extract.vbs ' ' 3. Extract.vbs uses 7za.exe and crx2rnx.exe to uncompress and decode ' ' SatRef Hatanaka-compressed RINEX files. ' ' 4. Store Extract.vbs, 7za.exe and crx2rnx.exe in the same folder. ' ' 5. Run Extract.vbs with file/folder as parameter at command line, e.g. ' ' Extract.vbs "c:\data folder\HKSL00HKG_R_20191880000_01D_30S_MO.crx.gz" ' ' Extract.vbs "c:\data folder\hkoh015e.19d.gz" ' ' Extract.vbs "c:\data folder" ' ' 6. Or Drag&Drop file(s) and folder(s) to Extract.vbs from File Explorer. ' ' 7. Uncompressed RINEX files will be extracted in the same folder(s) as ' ' the source .gz files. ' ' ' ' Reference: ' ' (a) Hanataka-compressed format is developed by Yuki Hatanaka of ' ' Geospatial Information Authority of Japan (GSI). Please visit GSI ' ' website http://terras.gsi.go.jp/ja/crx2rnx.html for details. ' ' (b) 7za.exe is a standalone console version of 7-Zip file archiver, ' ' please visit https://www.7-zip.org for details. ' ' ' ' Last Update: 2019-08-02 Total 5,436 bytes ' '---------------------------------------------------------------------------' Option Explicit Dim fso, objShell, i, gZipFile, ProgFolder, unZipEXE Dim count, allText Set fso = CreateObject("Scripting.FileSystemObject") Set objShell = CreateObject("WScript.Shell") ProgFolder = left(wscript.ScriptFullName, instrRev(wscript.ScriptFullName , "\")-1) unZipEXE = """" & ProgFolder & "\7za.exe""" '7-Zip count = 0 ' count total no. of unzipped file allText = "" for i = 0 to Wscript.Arguments.count - 1 gZipFile = Wscript.Arguments.item(i) If fso.FolderExists(gZipFile) = True then ProcessOneFolder Wscript.Arguments.item(i) elseIf fso.FileExists(gZipFile) = True then if lcase(right(gZipFile,3))= ".gz" then ProcessOneFile gZipFile end if end if next writeLog allText msgbox count & " file(s) extracted" & allText, , wscript.ScriptFullName wscript.quit '============================================== sub ProcessOneFolder(aFolder) Dim f2, f, sf set f2 = fso.GetFolder(aFolder) for each f In f2.files if lcase(right(f.name,3))= ".gz" then ProcessOneFile f.path end if next if f2.subFolders.count > 0 then for each sf In f2.subFolders ProcessOneFolder sf.path next end if end sub sub ProcessOneFile(aFile) dim outFolder, unZip, unZippedFile, HatanakaCommand, returnCode, outFile if instr(aFile, "\") >0 then outFolder = left(aFile, instrRev(aFile , "\")-1) else outFolder = ProgFolder end if unZip = unZipEXE & " e -y -o""" & outFolder & """ """ & aFile & """" ' ' ' ' ' '-- set Output directory ' ' ' '-- assume Yes on all queries, e.g. overwrite existing file ' '-- Extract files from archive (without using directory names) returnCode = objShell.run(unZip, 0, True ) ' ' 'Hide Window WaitOnReturn if returnCode <> 0 then exit sub end if unZippedFile = left(aFile, len(aFile)-3) If fso.FileExists(unZippedFile) = False then exit sub end if outFile = unZippedFile if lcase(right(unZippedFile,4))=".crx" or lcase(right(unZippedFile,1))="d" then HatanakaCommand = """" & ProgFolder & "\crx2rnx.exe"" -f """ & unZippedFile & """" returnCode = objShell.run(HatanakaCommand , 0, true ) ' ' 'Hide Window WaitOnReturn if returnCode = 0 then if lcase(right(unZippedFile,1)) = "d" then outFile = left(unZippedFile, len(unZippedFile)-1) & "o" else outFile = left(unZippedFile, len(unZippedFile)-3) & "rnx" end if fso.deleteFile unZippedFile end if end if If fso.FileExists(outFile) then count = count + 1 allText = allText & vbCRLF & count & ". " & outFile end if end sub sub WriteLog(strText) Dim objTextFile, LogFile LogFile = ProgFolder & "\ExtractLog.txt" Const ForAppending = 8, ForReading = 1, ForWriting = 2 on error resume next Set objTextFile = fso.OpenTextFile ( LogFile , ForAppending, True) objTextFile.WriteLine strText objTextFile.Close Set objTextFile = nothing on error goto 0 end sub