set theCommand to "date +%Y/%m/%d" set theDateString to do shell script theCommand set theDate to date theDateString 0813名称未設定2016/09/07(水) 02:17:43.35ID:GDz+ptgZ0 あ、上のは検証してないんで一応補足しておくけど、もし年/月/日の並びがだめぽな 環境があるなら>>811のような定番の方法を使ってそれぞれ別個に定義してやればよい
e.g. set theDate to current date set theYearString to do shell script "date +%Y" set (year of theDate) to theYearString ... 0814名称未設定2016/09/07(水) 04:47:46.77ID:3MTRzdxL0 OS10.9以上なら、Rubyのdateオブジェクトで西暦和暦変換ができるみたいです ただ、和暦はドット区切り、西暦はスラッシュ区切り固定のようなので、 入力する日付を自分でその形式に変換しておく必要あり (AppleScript's text item delimiters とif文を組み合わせればできる)
というか、本題からズレてたらすいません…
--和暦→西暦変換(ドット区切り・H(平成)・S(昭和)・T(大正)・M(明治)対応) set theDateStringJp to "S10.9.6" set theRubyScript to "require 'date';puts Date.parse(\"" & theDateStringJp & "\").strftime(\"%Y/%m/%d\")" set theDateString to do shell script "ruby -Ku -e " & quoted form of theRubyScript
--西暦→和暦変換(スラッシュ区切り・H(平成)・S(昭和)・T(大正)・M(明治)対応) set theDateString to "1935/09/06" set theRubyScript to "require 'date';puts Date.parse(\"" & theDateString & "\").jisx0301" set theDateStringJp to do shell script "ruby -Ku -e " & quoted form of theRubyScript 0815名称未設定2016/09/07(水) 08:09:40.71ID:3MTRzdxL0>>809 set theDateString to "2016/9/6" set theDate to date theDateString
set yearString to characters 1 thru 4 of theDateString as text set (year of theDate) to yearString
set afile to choose file set adesk to (path to desktop) as text tell application "Image Events" launch set the_image to open afile try save the_image as PICT in (file (adesk & "a.pict")) end try close the_image end tell 0821名称未設定2016/09/18(日) 18:54:18.94ID:ZyunKvGT0 pictは扱えなさそうな感じ 代わりにsipsコマンドでやると Error: Unsupported output format com.apple.pict 0822名称未設定2016/09/18(日) 22:05:15.44ID:RKOguUii0 標準のコマンドがダメなら brew install imagemagick して convert コマンドを使う手もある ImageMagick は PICT 形式に対応してるよ
ちなみに今時 PICT って何に使うんだい 0823名称未設定2016/09/19(月) 22:57:57.88ID:9rn6DICs0 過去スレでiTunesのアートワークとして画像を差し込む方法が載っていたのでその通りにやってみました. そこでは一度,画像データをpictに変換し,data of artwork に入れていました. 0824名称未設定2016/09/19(月) 23:29:01.85ID:9rn6DICs0 お騒がせしましたiTunes10.2から仕様が変わっていたのですね,,, tell application "iTunes" to set data of artwork 1 of theTrack to (read (file targetImageFile) as picture) これでできそうですね. 0825名称未設定2016/09/20(火) 01:57:42.90ID:0AeGId/70 そういうのは最初からやりたいことを全部言ったほうがいい 質問がズレてると回答もズレちまってお互い時間の無駄だ 0826名称未設定2016/11/08(火) 18:08:26.81ID:iTLgand+0 automatorで、上のメニューバーにはあるけどショートカットコマンドが与えられてない項目のショートカットを作りたいのですが、 自動記録したものを走らせてもエラーが出て動きません。 どのようなApple script を書けばいいか教えてください。 (例えばChromeの「ズーム」をショートカットにしたい場合) 0827名称未設定2016/11/08(火) 18:09:54.47ID:iTLgand+0 on run {input, parameters} -- ズーム set timeoutSeconds to 2.0 set uiScript to "click menu item 3 of menu 1 of menu bar item 9 of menu bar 1 of application process \"Chrome\"" my doWithTimeout(uiScript, timeoutSeconds) return input end run
on doWithTimeout(uiScript, timeoutSeconds) set endDate to (current date) + timeoutSeconds repeat try run script "tell application \"System Events\" " & uiScript & " end tell" exit repeat on error errorMessage if ((current date) > endDate) then error "Can not " & uiScript end if end try end repeat end doWithTimeout
tell application id "com.apple.systemevents" tell application "Google Chrome" to activate --これは呼び出し方によっては不要 tell process "Google Chrome"'s first menu bar's menu bar item "ウインドウ"'s menu "ウインドウ"'s menu item "ズーム" to click end tell 0830名称未設定2016/11/18(金) 11:32:35.49ID:tGiTS7790 AppleScript他自動化ツールはこの先どうなる https://www.macintouch.com/forums/showthread.php?tid=1189 Apple dumps Sal Soghoian, who gave us Mac automation tools 0831名称未設定2016/11/18(金) 11:49:53.23ID:0sQ3zW0a0 いつの間にかiTunesでdisplay dialogとdisplay alertのcancel buttonが効かなくなってる 0832名称未設定2016/11/18(金) 15:06:19.50ID:FWfCUeTi0>>830 やべぇよやべぇよ…… ほんこれ >Another nail in the coffin of macOS being a tool for professionals. 0833名称未設定2016/11/18(金) 21:18:06.86ID:GUceBYRw0 Rhapsody発表時にAppleScriptも廃止する予定とジョブズが言ったとたん じゃぁもうMac使ってる意味ねーよ安いAT機買うからとプロ業界から総スカンをくらい なんと思い直したというMac自動化の歴史も、彼なき後、遂に終焉を迎えるわけですな 0834名称未設定2016/11/21(月) 20:23:02.65ID:7ymhH/7S0 Swiftインタプリタでなんとかしてくれるの? 0835名称未設定2016/11/21(月) 20:28:14.32ID:EK10STwB0 SwiftScriptまだ〜? 0836名称未設定2016/11/22(火) 23:21:03.30ID:ICQ6tb5N0 相談です。 最近、iTunes用の以下のスクリプトで動画ファイルの種類を変更しようとするとパラメーターのエラーです、というエラーが出てしまいます。 なぜか、TV showへの変更はうまくいき、movieやmusic videoへの変更が失敗します。
tell application "iTunes" --return (item 1 of selection) set video kind of (item 1 of selection) to movie end tell 0837名称未設定2016/11/23(水) 03:04:10.30ID:enXikOrW0 home video/movie/music video/TV show
どれに変えてもエラーにならなかった 0838名称未設定2016/11/23(水) 12:49:43.28ID:WM8UhP380 ありがとうございます。 環境依存っぽいですね。 0839名称未設定2016/11/23(水) 13:51:26.26ID:tAdkg8UK0 バージョンは? コンパイルしなおしたか? できるファイルもあるのか? 何かの tell ブロックに入れ子になってたりして用語衝突してないか? 0840名称未設定2016/11/23(水) 17:09:26.13ID:sz1Dt2/Q0 Mac OS X 10.9.5 AppleScript 2.3.2 iTunes 12.4.3.1 でした。 いくつかのファイルを試しましたが、やはりTV showへの変更しかできませんでした。 他はエラーが返ります。 「iTunesでエラーが起きました:パラメーターのエラーです」 入れ子ではなく、スクリプトエディタでそのまま実行してもエラーになります。 0841名称未設定2016/11/23(水) 18:37:33.33ID:60Z7tgsL0 iTunes上で直接変更はできるの? 0842名称未設定2016/11/23(水) 20:59:45.08ID:sz1Dt2/Q0 はい、可能です。 今は手動でやってます。 0843名称未設定2016/11/24(木) 04:46:23.72ID:QhkCG5JO0 気になる話があった http://dougscripts.com/410 Set Video Kind of Selected v5.2 WARNING: a possible bug in iTunes 12.4.1 and later prevents this script from working. Until Apple confirms and/or addresses this issue, I do not recommend using this script. 0844名称未設定2016/11/24(木) 15:10:30.69ID:ZN/5pbPK0 Doug氏がそう言うんならそうなんだろうな 0845名称未設定2016/11/24(木) 16:39:48.30ID:5Qm7ZEkl0 原因不明で回避方法もないということでしょうか。 残念。 0846名称未設定2016/11/24(木) 17:14:49.09ID:ZN/5pbPK0 不明というか、iTunes側のバグって話かと 0847名称未設定2016/11/25(金) 14:24:33.44ID:muoB3U8+0 os 10.11です デフォルトプリンタとデフォルトの用紙の設定をアップルスクリプトから制御したいのですが、プリンター設定ユーティリティがなくなってしまい、以前使っていたスクリプトが動かなくなりました System Eventsからorg.cups.PrintingPrefs.plistを直接いじればいけるかなと思ったのですが、エラーになって設定できません 何かいい方法はありませんでしょうか 08488472016/11/25(金) 17:43:59.31ID:muoB3U8+0 shell script でデフォルトのプリンターの変更ができるものを検索して見つけました ですがデフォルト用紙は見つけられませんでした… 0849名称未設定2016/11/26(土) 04:23:35.33ID:VhEWogO40 defaults write org.cups.PrintingPrefs DefaultPaperID "iso-a4" とかで行けるっぽいよ 参 http://themacadmin.com/mavericks-updatesetting-a-default-paper-size/