タグ別アーカイブ: Finder

[AppleScript] Finderで複数選択している項目を1つずつzipで圧縮

1つずつってのがミソです。
複数選択している状態で圧縮すると、デフォルトではまとめて圧縮されてしまいます。
しかしときには1つずつ圧縮したいケースもあるでしょう。(というか直面した)
コードは相変わらず9割コピペ。僕の仕事はGrowlを設定しただけ。
dittoが初参加です、ちょっと調べるとこれ便利ですね。これからお世話になりそう。
ditto(1) Mac OS X Manual Page

あと、今回のような時間がかかるときはGrowl入れる意味があって嬉しいです。
いつも自己満なんで。。。
しかし、ファイル操作のときはshell大活躍すぎてAppleScriptで書く意味がががが・・・
AppleScriptは当然として、shellも知っとかないとですねぇ。覚えることが多いっす。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
set i to 0
	tell application "Finder"
		set fol_Path to (target of window 1) as alias
		repeat with select_item in (selection as list)
			set file_path to select_item as alias
			set fil_name to name of file_path as text
			set source to quoted form of POSIX path of (file_path as text)
			set dest to quoted form of POSIX path of (fol_Path & fil_name & ".zip" as text)
			do shell script "ditto -ck " & source & " " & dest
			delay 1
			set i to i + 1
		end repeat
	end tell
	set grrDescription to i & "files" as text
	my growlRegister()
	growlNotify("End Run Zip", grrDescription)
 
 
using terms from application "GrowlHelperApp"
	on growlRegister()
		tell application "GrowlHelperApp"
			register as application "選択項目をzipで圧縮" all notifications {"Notification"} default notifications {"Notification"} icon of application "Finder.app"
		end tell
	end growlRegister
	on growlNotify(grrTitle, grrDescription)
		tell application "GrowlHelperApp"
			notify with name "Notification" title grrTitle description grrDescription application name "選択項目をzipで圧縮"
		end tell
	end growlNotify
end using terms from

カテゴリー: AppleScript | タグ: | コメントをどうぞ

[AppleScript] Finderで選択した項目のいろんな情報を取得

スマートなコードを見つけたのでご紹介。

AppleScriptでググったらまずヒットするザリガニが見ていた…。さんから。

選択中したファイルのいろんな情報を引っ張り出します。

大抵はshellで取得すると思うんですが、これはprpertyから抜き取ります。

無理がなく、AppleScriptだけってのもステキ。

一気にいろんな情報が取れて便利ですねー。

ついでですが、a7、a8にパス関係を追加してます。(僕が使いたかっただけ)

カテゴリー: AppleScript | タグ: | コメントをどうぞ

[AppleScript] テキストをデリミタで分割してリスト化

テキストをリスト化する構文。


Finderからパスを取得した場合などによく使ってます。


拡張子、ファイル名、階層数を受け取りたいときは便利。

カテゴリー: AppleScript | タグ: | コメントをどうぞ

[AppleScript] Finderで選択中の項目をリネーム

今日からApple Scriptの書き溜めをブログにしていこうと思います。


スクリプト書くとき、簡単なルーチンはEvernoteにメモで残してるんですが、それだとあんまり実用性が無いので。


というのも、ただコピペするだけだと、こんな感じになるから。

カテゴリー: AppleScript | タグ: | コメントをどうぞ