MDIEスクリプト 「clipFolder.js」

ソースコード (clipFolder.zip をダウンロード)

/**
 * clipFolder.js
 *   新規フォルダの名前をクリップボードにある文字列で作成
 * 
 * @author  mizugame (html://picsmate.net/)
 * @version 0.1.0 (2008-12-7)
 * @license GPL
 */

if (typeof MDIE.Clipboard == 'string') {
  var $fso  = new ActiveXObject("Scripting.FileSystemObject");
    $name   = MDIE.Clipboard
      .replace(/\s+/g, ' ')
      .replace(/[\t\\\/:;*?<>|]/g, '-')
      .replace(/^\s+|\s+$/g, '');
    $path   = $fso.BuildPath(FolderView.Path, $name);
  
  if ($fso.FolderExists($path) || $fso.FileExists($path)) {
    for (var i=1; ($fso.FolderExists($path) || $fso.FileExists($path)); i++) {
      $path = $fso.BuildPath(FolderView.Path, $name + '(' + i + ')');
    }
  }
  $fso.CreateFolder($path);
} else {
  MDIE.Command(5212);
}
記事に戻る