1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【Mac】WindowsみたいにFinderからファイルを新規作成できるようにしてみた

Last updated at Posted at 2026-01-14

Finderって使いにくい!

Finderの地味に使いにくいポイントとしてファイルを新しく作れないが挙げられると思います。
Windowsだと新規作成でパッと作れるんですが...
今回はWindowsとほぼ同じ手軽さでFinderで新規ファイルを作れるようにしてみました。

使うもの

  • ショートカット
  • Apple Script (コピペでOK)

完成系

Finderで右クリックするとアクションを起動できます。
ショートカットの仕様上、既存のファイルに右クリックしないとクイックアクションを呼べません(悲しい)
スクリーンショット 2026-01-14 11.34.38.png

起動すると、テキスト入力欄が出ます。
ここにファイル名を入力すると、現在のパスにファイルが作成されますし、"/"で区切るとフォルダまで作ってくれます。
"."から始まるファイルでも作成できます。

スクリーンショット 2026-01-14 11.34.56.png
スクリーンショット 2026-01-14 11.35.17.png

手順

ショートカットの作成

新しいショートカットを作成します。

スクリーンショット 2026-01-14 11.41.09.png

右上のℹ️マークからクイックアクションとして使用Finderにチェックを入れてください。

スクリーンショット 2026-01-14 10.46.47.png

AppleScriptを実行

次に、検索のところでAppleScriptを実行を検索し、追加してください。
そして、以下のコードをコピペしてください。
ペーストすると紫色になると思いますが、🔨ボタンを押すと文法のチェックがされます。

on run {input, parameters}
	tell application "Finder"
		activate
		
		try
			-- 現在のウィンドウのターゲットを取得
			set currentTarget to (target of front window) as alias
			set currentPath to POSIX path of currentTarget
		on error
			-- ウィンドウがない場合はデスクトップ
			set currentPath to POSIX path of (path to desktop)
		end try
		
		-- 入力ダイアログを表示
		set userInput to text returned of (display dialog "作成するファイル名を入力してください" default answer "" with title "新規ファイル作成" with icon note)
	end tell
	
	if currentPath ends with "/" then
		set fullPath to currentPath & userInput
	else
		set fullPath to currentPath & "/" & userInput
	end if
	
	-- 結合されたフルパスを返す
	return fullPath
end run

こんな感じになればOKです。

スクリーンショット 2026-01-14 11.48.13.png

シェルスクリプトを実行

次に、検索のところでシェルスクリプトを実行を検索し、追加してください。
そして、以下のコードをコピペしてください。

シェルzsh
入力AppleScript実行結果(入力するとサジェストが出てきます)
入力を渡す方法引数

としてください。

export LANG=ja_JP.UTF-8

TARGET_PATH="$1"

if [[ "$TARGET_PATH" == */ ]]; then
    # 末尾がスラッシュ
    mkdir -p "$TARGET_PATH"

else
    # 末尾がスラッシュ以外
    
    DIR_PATH=$(dirname "$TARGET_PATH")
    if [ ! -d "$DIR_PATH" ]; then
        mkdir -p "$DIR_PATH"
    fi

    touch "$TARGET_PATH"
fi

こんな感じになればOKです。

スクリーンショット 2026-01-14 11.49.21.png

これができたらFinderでクイックアクションが呼び出せます!
AppleScriptだとできることが少ないですが、ショートカットからシェルコマンドも実行できると色々できそうです!(Pythonも実行できるっぽい)
ファイルの上で右クリックしないと表示されないのが少し不便ですが...

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?