Last active
December 21, 2015 07:59
-
-
Save tomsteele/6275546 to your computer and use it in GitHub Desktop.
Converts bat file into compatible VBA string.
This file contains 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
#!/usr/bin/env ruby | |
content = File.open(ARGV[0]).read | |
# sub escaped double quote for single quote | |
content.gsub!(/\\\"/, "'") | |
# sub double quote for decimal double quote | |
content.gsub!(/\"/, '" & Chr(34) & "') | |
# add cmd.exe for execution | |
content = '"cmd.exe /C ' + content | |
# split every 200 chars and then rejoin with newline and string continuation | |
content = content.scan(/.{1,200}/).join("\" & _\r\n\"") | |
content += '"' | |
puts content |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment