-
-
Save hokorobi/5245532 to your computer and use it in GitHub Desktop.
PPx
2ch で話題に上ったので、使う予定もないのに手を加えてみた。
UTF-8で処理するようにした。テストしてないけど。
フォルダもリネームできるようにした。
例外を使ってみたけど改悪っぽい。そのほかちょびちょび変更。
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
//!*script | |
// This script is in the public domain. | |
// PPc 用スクリプト。 | |
// 選択エントリーをテキストエディタで一気にリネーム。 | |
// PPx 1.30 x64 + Script Module R14 | |
if (PPx.DirectoryType != 1 && PPx.DirectoryType != 4) { | |
PPx.Echo('現在のパスではリネームできません。'); | |
PPx.Quit() | |
} | |
if (PPx.EntryMarkCount == 0) { | |
PPx.Echo('マークされたエントリがありません'); | |
PPx.Quit(); | |
} | |
// PPx側でエディター設定していればそれを使う。 | |
// 指定なしorエディタが存在しない場合はPPeで編集する。 | |
//var editor = PPx.Extract("%'editor'"); | |
var editor = PPx.Extract("%'xyzzy'"); | |
// ファイル操作 | |
var fso = new ActiveXObject('Scripting.FileSystemObject'); | |
editor = fso.GetAbsolutePathName(editor); | |
// マークしたファイルのリストを取得 | |
var listFile = PPx.Extract('%a*8FCN'); | |
if (fso.FileExists(editor)) // 指定エディタで起動 | |
PPx.Execute('%Obsq "' + editor + '" "' + listFile + '"'); | |
else // 指定エディタが設定されていない場合は PPe で | |
PPx.Execute('*edit "' + listFile + '"'); | |
// 編集したファイルを読む | |
try { | |
var f = new ActiveXObject('ADODB.Stream'); | |
f.Type = 2; | |
f.Charset = 'UTF-8'; | |
f.Open(); | |
f.LoadFromFile(listFile); | |
var newFileNames = f.ReadText(-1).split(/\r\n/); | |
f.Close(); | |
} catch (e) { | |
PPx.Echo('リネームデータを取得できませんでした'); | |
PPx.Quit(); | |
} | |
if (newFileNames.length != PPx.EntryMarkCount) { | |
PPx.Echo('リネームデータ数とマーク数に差異があります'); | |
PPx.Quit(); | |
} | |
// エントリのリネーム | |
var oldalst = PPx.Extract('%*getcust(XC_alst)'); | |
PPx.Execute('*customize XC_alst=1,1,1,1,1'); | |
var dir = PPx.Extract('%1%\\'); | |
for (var i = 0; PPx.EntryFirstMark == 1; i++) { | |
var oldName = fso.getAbsolutePathName(PPx.EntryName); | |
var newName = fso.getAbsolutePathName(newFileNames[i]); | |
PPx.EntryMark = 0; | |
if (oldName == newName) continue; | |
PPx.Execute('*rename "' + oldName + '","' + newName + '"'); | |
} | |
PPx.Execute('*customize XC_alst=' + oldalst); | |
// 再読み込み | |
PPx.Execute('*jumppath /refreshcache /savelocate'); | |
PPx.Quit(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment