//MELで書いてます! //何に使っても構いません。 //再配布もOKです。 //ただ何が起きても責任は負いかねます。 //-------------------------------------------------- //ウィンドウパネルの作成 //-------------------------------------------------- window -title "ReNameTool ver 1.2" ; columnLayout ; text -label "置換前の文字。" ; textField -tx "" targetMoji; text -label "置換後の文字(未記入で削除できます)。" ; textField -tx "" changedMoji; separator -h 10 -w 300 ; separator -h 10 -w 300 ; text -label "接頭辞を追加します。" ; textField -tx "" prefix ; text -label "接尾辞を追加します。" ; textField -tx "" suffix ; separator -h 10 -w 300 ; separator -h 10 -w 300 ; text -label "チェックボックスオンで連番追加します。以下桁数。" ; checkBox -label "連番追加" renbanCheck ; intField -value 4 ketaNumber; text -label "チェックボックスオンで、名前一括変更します。" ; text -label "連番追加しなければ変更できません。" ; checkBox -label "名前全変換" baseNameChangeCheck ; textField -tx "" baseName ; separator -h 10 -w 300 ; separator -h 10 -w 300 ; setParent ..; rowLayout -numberOfColumns 2 -columnWidth2 60 20 ; button -label "変換実行" -c exchangeMoji ; button -label "名前書き出し" -c exportText ; setParent ..; showWindow ; //-------------------------------------------------- //リネームの処理 //-------------------------------------------------- global proc exchangeMoji() { string $moto = `textField -q -tx targetMoji`; string $ato = `textField -q -tx changedMoji`; string $mae = `textField -q -tx prefix` ; string $usiro = `textField -q -tx suffix` ; string $temp ; string $number ; int $c = `checkBox -q -v renbanCheck` ; int $cc = `checkBox -q -v baseNameChangeCheck` ; string $sentaku[] = `ls -sl -tr` ; int $kazu = ` size ( $sentaku ) ` ; int $x ; if(0==$cc) //全名前変更の時はオフにしています { for ($x=0 ; $x < $kazu ; $x++){ string $temp = substitute ( $moto ,$sentaku[$x] , $ato ); rename $sentaku[$x] ($mae + $temp + $usiro + $number) ; }; }; if(1==$c) { for ($x=0 ; $x < $kazu ; $x++) { string $temp = $sentaku[$x] ; string $r = $x ; $number = 0 ; int $i; int $keta = `intField -q -v ketaNumber`- 1 ; for($i=size($r); $i < $keta ; $i++) { $number = "0" + $number ; }; if(1==$cc) { $temp = `textField -q -tx baseName` ; }; rename $sentaku[$x] ( $temp + "_" + $number + $x); }; }; }; //-------------------------------------------------- //名前書き出しの処理 //-------------------------------------------------- global proc exportText() { string $sentaku[] = `ls -sl -tr` ; int $kazu = `size($sentaku)`; int $x ; string $exampleFileName = "D:/NameList.txt" ; $fileId = `fopen $exampleFileName "w"`; for ($x=0 ; $x < $kazu ; $x++) { fwriteAllLines($exampleFileName,$sentaku) ; print ($sentaku[$x] + "\n"); } ; fclose $fileId ; };
こちらから門を叩いてね!
https://hexadrive.jp/recruit/joblist/