Home > AppleScript > [ AppleScript ] 選択階層に新規フォルダを作成するスクリプト

[ AppleScript ] 選択階層に新規フォルダを作成するスクリプト

選択階層に新規フォルダを作成する AppleScript のサンプルです。

  • Mac OS X の Finder でリスト表示していると、任意の場所で新規フォルダが作りにくい。
  • 普通に「新規フォルダ」を選択すると、リスト表示している最上層にフォルダが作られてしまう。
  • コンテクストメニューかスクリプトで何とかならんだろうか…。

なんて考えて作ってみました。

  • フォルダを選択していたら、その中に新規フォルダを作成。
  • ファイルを選択していたら、同階層に新規フォルダを作成。
  • 複数項目を選択していると、その分処理を繰り返し。
tell application "Finder"
  repeat with ThisFile in (selection as list)
    set a to (ThisFile as alias) as text
    if a ends with ":" then
      make new folder at (a as alias)
    else
      make new folder at (my MyFilePath(a) as alias)
    end if
  end repeat
end tell
on MyFilePath(this_text)
  set y to 0
  repeat with thisChar in this_text
    set y to y + 1
    set x to the offset of thisChar in ":"
    if x is not 0 then
      set z to y
    end if
  end repeat
  return (text from character 1 to z of this_text)
end MyFilePath

動作確認:Mac OS 10.4.8

Comments:0

コメントフォーム

お気軽にコメントをどうぞ! コメントを頂けると管理人が喜びます。

情報を記憶しますか?

Trackbacks:1

Trackback URL for this entry
http://bowz.info/1245/trackback
Listed below are links to weblogs that reference
[ AppleScript ] 選択階層に新規フォルダを作成するスクリプト from Bowz::Notebook
trackback from GameSprit 06-11-19 (日) 9:51

AppleScript でファイルを作成する(Finder 操作)

AppleScript を使って Finder を操作し新しいファイルを作成してみます

Home > AppleScript > [ AppleScript ] 選択階層に新規フォルダを作成するスクリプト

Feeds
Meta
あわせて読みたいブログパーツ

Return to page top