home *** CD-ROM | disk | FTP | other *** search
/ DOS/V Power Report 2002 July / VPR0207A.ISO / OLS / IRVINE0_4_1A / irvine0_4_1a.lzh / scripts / listreplacefilename.dms < prev    next >
Text File  |  2002-03-10  |  1KB  |  57 lines

  1. /*スクリプト初期化イベント
  2. guid={92f02e38-a11a-466f-b8c6-af8d86eeea74}
  3. caption=保存ファイル名の置換
  4. version=2
  5. hint=選択アイテムの保存ファイル名を置換します
  6. event=OnListMenuClick
  7. match=
  8. author=名無しさん@お腹いっぱい
  9. */
  10.  
  11. function OnListMenuClick(irvine,action){
  12.   item = new IrvineItem;
  13.   reg = new RegExp;
  14.   reg.source = prompt('置換前(正規表現で指定できます)', '');
  15.   if(!reg.source) 
  16.     return;
  17.   
  18.   after = prompt('置換後', '');  
  19.   if(after == null) 
  20.     return;   
  21.     
  22.   irvine.BeginProgressBar(irvine.SelectedItemCount);
  23.   try{
  24.     for(i = 0; i < irvine.ItemCount; i++){
  25.       if (irvine.GetItemSelected(i)){
  26.         item.data = irvine.GetItemData(i);
  27.         
  28.         if(item.filename != '') 
  29.           tmp = item.filename;
  30.         else {
  31.           delimindex = item.url.lastIndexOf('/');
  32.           tmp = item.url.slice(delimindex + 1,item.url.length - 1);
  33.         }
  34.         
  35.         tmp2 = reg.replace(tmp, after); 
  36.         if(tmp == tmp2)
  37.           tmp2 = item.filename;
  38.           
  39.         item.filename = tmp2;
  40.         irvine.SetItemData(i, item.data);
  41.         irvine.ProgressBarStepBy(1);
  42.       } 
  43.     }  
  44.   }  
  45.   
  46.   finally{    
  47.     irvine.EndProgressBar(); 
  48.     irvine.Invalidate();
  49.   }
  50. }
  51.  
  52. function OnMenuUpdate(irvine,action){
  53.   action.enabled = (irvine.SelectedItemCount > 0);
  54. }
  55.  
  56.  
  57.