
Launchpadから[その他]のグループアイコンの中にAutomatorがいるので起動。

サービスをクリックして[選択]ボタンを押す。


デフォルトだとこうなっているのでクリックして対象を
[ファイルまたはフォルダ]に変更



property defaultFileName : "newTextFile"
on run {input, parameters}
try
tell application "Finder" to set the sourceFolder to (folder of the front window) as alias
on error
-- no open folder windows
set the sourceFolder to path to desktop folder as alias
end try
set flagFileExists to true
set indexFile to ""
repeat while flagFileExists
set indexFile to (indexFile + 1)
tell application "Finder"
set flagFileExists to (exists file (defaultFileName & indexFile & ".txt") in sourceFolder)
end tell
end repeat
try
tell me
activate
set newFileName to text returned of (display dialog "Enter new file name" default answer "" & defaultFileName & indexFile)
end tell
if newFileName is not equal to "" & defaultFileName & indexFile then
set defaultFileName to newFileName
end if
set newFile to "" & sourceFolder & newFileName & ".txt"
if not flagFileExists then
set touchScript to "touch " & quoted form of (POSIX path of newFile)
set openScript to "open " & quoted form of (POSIX path of newFile)
do shell script touchScript
do shell script openScript
else
display dialog "File already exists"
end if
end try
return input
end run

ハンマーボタンを押してコンパイルしましょう。

色が変わります。
以上!

あとは

[ファイル]ー[保存]
で今作ったスクリプトを保存です。
ファイル名は[ファイル作成]とかで可。
フォルダ名のところで右クリックしたところ

メニューが出て [ファイル作成] が出ました。

Finder の Cover Flow表示だとフォルダが見えないから、
ファイルの上で右クリックすれば新規作成できますね。

いじょ。

対象OS:Mac OS X 10.8.X (Mountain Lion)
0 件のコメント:
コメントを投稿