//!*script // カーソル位置フォルダからepubファイルを作成 Ver 1.0 // 使用エイリアス:Winrar // ============================================================ // 変数宣言 var iDir = ''; // 入力ファイルディレクトリ名 var command = ''; // PPxコマンドワーク var FSOObj = ''; // ファイルシステムオブジェクト var WSHObj = ''; // wshシェル var RetCD = ''; // 戻り値 // カーソル位置エントリの取得 iDir = PPx.Extract('%FDN%\\%R'); // ディレクトリチェック command = PPx.EntryAttributes & 0x10; if (command != 0x10) { PPx.Quit(); } // mimetype存在チェック FSOObj = new ActiveXObject('Scripting.FileSystemObject'); if (!FSOObj.FileExists(iDir + '\\mimetype')) { FSOObj = ''; PPx.Quit(-1); } FSOObj = ''; // 念のためファイル削除 PPx.Execute('*delete "' + iDir + '.zip"'); PPx.Execute('*delete "' + iDir + '.epub"'); // zip書庫の初期作成 WSHObj = new ActiveXObject('WScript.Shell'); command = PPx.Extract('%\'Winrar\'') + ' a' // 書庫に追加 + ' -afzip' // zip書庫 + ' -m0' // 無圧縮 + ' -ep1' // ベースフォルダを除外 + ' "' + iDir + '.zip"' + ' "' + iDir + '\\mimetype"'; RetCD = WSHObj.Run(command,1,true); // true:終了待機する if (RetCD != 0) { // 戻り値チェック command = '"' + (PPx.ScriptName).replace(/^.+\\(.+$)/,'$1') + '"' + ' "エラーコード=' + RetCD + ' 終了します"'; PPx.Echo(command); WSHObj = ''; PPx.Quit(); } // zip書庫の主作成 command = PPx.Extract('%\'Winrar\'') + ' a' // 書庫に追加 + ' -afzip' // zip書庫 + ' -m3' // 標準圧縮 + ' -ep1' // ベースフォルダを除外 + ' -r' // 再帰処理 + ' -xmimetype' // mimetypeを除外 + ' "' + iDir + '.zip"' + ' "' + iDir + '\\*"'; RetCD = WSHObj.Run(command,1,true); // true:終了待機する if (RetCD != 0) { // 戻り値チェック command = '"' + (PPx.ScriptName).replace(/^.+\\(.+$)/,'$1') + '"' + ' "エラーコード=' + RetCD + ' 終了します"'; PPx.Echo(command); WSHObj = ''; PPx.Quit(); } // zip -> epub リネーム command = '*rename "' + iDir + '.zip","' + iDir + '.epub"'; PPx.Execute(command); // 後処理 WSHObj = ''; PPx.Quit();