Last active
December 25, 2015 13:07
-
-
Save motoraku/8ad5d9eb0790a17cf2ee to your computer and use it in GitHub Desktop.
バイナリファイルをテキストファイルへ変換 : Convert binary file to text file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| WScript.Quit((function() { | |
| // 入力ファイル名、出力ファイル名を受け取る | |
| if(WScript.Arguments.length < 1) { | |
| //WScript.Echo("args : (path) (out text file path)"); | |
| WScript.Echo("args : (path) (out text file path)"); | |
| return 1; | |
| } | |
| // ファイル読み込み | |
| var ins = WScript.CreateObject('ADODB.Stream'); | |
| ins.Open(); | |
| ins.Charset = "iso-8859-1"; | |
| ins.Type = 1; // Binary | |
| ins.LoadFromFile(WScript.Arguments.item(0)) | |
| // バイト配列操作用オブジェクト | |
| var binMan = WScript.CreateObject('Microsoft.XMLDOM').createElement('tmp'); | |
| binMan.dataType = "bin.base64"; | |
| binMan.nodeTypedValue = ins.Read() | |
| ins.Close() | |
| ins = null; | |
| // ファイル書き込み | |
| var outs = WScript.CreateObject('ADODB.Stream'); | |
| outs.Open(); | |
| outs.Charset = "iso-8859-1"; | |
| outs.Type = 2; // Text | |
| outs.WriteText(binMan.text); | |
| binMan = null; | |
| outs.SaveToFile(WScript.Arguments.item(0)+".txt", 2); | |
| outs.Close(); | |
| outs = null; | |
| return 0; | |
| })()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment