Skip to content

Instantly share code, notes, and snippets.

@you21979
Last active December 14, 2015 05:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save you21979/5035648 to your computer and use it in GitHub Desktop.
Save you21979/5035648 to your computer and use it in GitHub Desktop.
windowsデスクトップに用意しておき、ドラッグアンドドロップにて複数選択したファイルを個別にzipファイルを作成する。
// -----------------------------------------------
var sCmd="C:\\Program Files\\7-Zip\\7z.exe";
var sOpt="a -tzip -mx=9 -mfb=32 -mmt=3 -r";
// -----------------------------------------------
function PathQuating(str){
return "\""+str+"\"";
}
function main(){
var appName = "7zip";
var winWidth = 800;
var winHeight = 150;
var HTML_CFG_CONSOLE = "toolbar=no,location=no,directories=no," +
"status=no,menubar=no,resizable=no," +
"width=" + winWidth + ",height=" + winHeight;
with ( new ActiveXObject("htmlfile").Script.
open("about:blank", "_blank", HTML_CFG_CONSOLE) ) {
try{
// ウィンドウを画面のセンターへ移動
moveTo(screen.availWidth / 2 - winWidth / 2,
screen.availHeight / 2 - 150 / 2);
document.write("<html>");
document.write("<head>");
document.write("<title>" + appName + "</title>");
document.write("</head>");
document.writeln("<body><pre>");
var oShell = new ActiveXObject("WScript.Shell");
var oArgs = WScript.Arguments;
for (i = 0; i < oArgs.length; ++i){
var outfile=oArgs(i)+".zip";
var command=PathQuating(sCmd)+
" "+
sOpt+
" "+
PathQuating(outfile)+
" "+
PathQuating(oArgs(i));
document.writeln(outfile + " ("+(i+1)+"/"+ oArgs.length +")");
oShell.Run(
command,
0,
true
);
}
document.writeln("</pre></body></html>");
}catch(e){
WScript.Echo(e.name + "\t" + e.message + "\t" +
Number(e.number & 0xffff).toString() + "\t" + e.description);
}finally{
try{
// ウィンドウを閉じる
close();
WScript.Echo("終了しました");
}catch(e){
}
}
}
}
main();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment