対象ã®è§¦ãæ¹
GUIç°å¢ã«ãããæä½ã®åºæ¬ã¯ãæä½å¯¾è±¡ãé¸æãã¦ãå½ä»¤ãããã¨ã§ããããã¹ã¦ã®æä½ã¯ãä½ããã©ããããã¨ããç®çèªã¨è¿°èªã®é¢ä¿ã§è¡¨ç¾ã§ãããï¼ãã¡ãããæä½ãã¦ããã®ã¯ã¦ã¼ã¶ã¼èªèº«ãªã®ã ããã主èªã¯ã¦ã¼ã¶ã¼ã§ãããã§ããããã§ã¯ãã¾ãéè¦ã§ãªãï¼
GUIã®æä½ã¯åãã¦ã®äººã«ãåãããããã®ã ãã©ãæ £ãã¦ããã¨ãã®åé·ãªæä½ãé¢åèããªã£ã¦ãããããã§ãã¼ãã¼ãã·ã§ã¼ãã«ãããã¨ããä»çµã¿ãç¨æããããcommand-Cã§ã³ãã¼ã¨ããcommand-Wã§ã¦ã£ã³ãã¦ãéããã¨ãããã¼ã®çµã¿åããã§GUIãæä½ããä»çµã¿ã ã
ãã¶ããæ £ãã¦ãã人ã»ã©ã·ã§ã¼ãã«ãããå¤ç¨ãã¦ãç´ æ©ãæä½ãå®ç¾ãã¦ããã¨æãããã½ã³ã³ã¯ãã¼ãã¼ãã¨ã³ãã³ãã©ã¤ã³ã§æä½ããCUIããããã¦ã¹ã¨ã°ã©ãã£ãã¯ã§æä½ããGUIã«é²åãããã©ãããå¹çãæ±ããã¨CUIã«å帰ãã¦ããã¨ããé¢ç½ãç¾è±¡ã ã
ããã«å¹çãæ±ããã¨ãã¹ã¯ãªããè¨èªã使ãå§ãããéå±ãªç¹°ãè¿ãå¦çãã¾ã¨ãã¦å®è¡ããããè¤éã§ééãæãå¦çãæ£ç¢ºã«å®è¡ãããã
ã¨ããã§ãCUIç°å¢ã¨ã¹ã¯ãªããè¨èªã¯ãæé«ã«ç¸æ§ããããã©ã¡ããCUIç°å¢ãªã®ã§ããä½ããã®æ å ±ã®ä¼éãç´æçã§ã¹ã ã¼ãºãªã®ã ã
- åºæ¬çã«ãã¡ã¤ã«ãã¹ããããã¯ããã¹ããã¼ã¿ãæå®ãããã¨ãå¤ãã
- ãã¾ã«ããã¼å ¥åããããã¯ã¯ãªãããã¼ããæå®ãããã¨ãããããã
ä¸æ¹ãGUIç°å¢ã¨ã¹ã¯ãªããè¨èªã¯ãGUIç°å¢ã§çã£ã対象ãä½ããã®é¨åãã¹ã¯ãªããè¨èªã§è¡¨ç¾ããã®ã«è¦å´ãããã¨ãå¤ãããã©ããããã®é¨åã®å¦çæ¹æ³ã¯æ確ã«åãã£ã¦ããã®ã«ããä½ããã®é¨åã®è¡¨ç¾ã®ä»æ¹ã«è©¦è¡é¯èª¤ãã¦ãæéãåããã¦ãã¾ãã®ã ...ã
æä½å¯¾è±¡ãã©ããã£ã¦åå¾ããã®ãããã®æ¹æ³ãããã¤ãæ¢ã£ã¦ã¿ãã
Finderã§é¸æä¸ã®ãã¡ã¤ã«ã対象ã«ãã
ãããããã¡ãªç¶æ³ã¨ãã¦ã¯ãFinderã§é¸æä¸ã®ãã¡ã¤ã«ã«å¯¾ãã¦ä½ããã®å¦çãå®è¡ãããã¨ãä¾ãã°ãradikoã®.flvãã¡ã¤ã«ãHE-AACã«å¤æãã¦iTunesã«ç»é²ããã¨ãã
AppleScriptã®å ´å
- Finderã®é¸æé ç®ã¯selectionã§åå¾ã§ããã
- ãã®å 容ã¯ãFinder fileåç §ã®ãªã¹ãã«ãªã£ã¦ããã
- ä¸ã¤ã ãé¸æã»è¤æ°é¸æã«é¢ä¿ãªãã常ã«ãªã¹ãã«ãªã£ã¦ããã
- repeatã§ãªã¹ãã®ä¸ã®Finder fileåç §ãä¸ã¤ãã¤åãåºãã¦å¦çãã¦ããã
tell application "Finder" to set select_list to selection
--çµæï¼{document file "test_path_to.me.scpt" of folder "Desktop" of folder "zari" of folder "Users" of startup disk of application "Finder"}
repeat with f in select_list
f --Finder fileåç §ãªã¹ãã®1çªç®ã®ã¢ã¤ãã
--çµæï¼item 1 of {document file "text_alias_posix_fileå¤æ.scpt" of folder "_Development" of folder "Scripts" of folder "Library" of folder "zari" of folder "Users" of startup disk of application "Finder"}
f as alias
--çµæï¼alias "Macintosh HD:Users:zari:Library:Scripts:_Development:text_alias_posix_fileå¤æ.scpt"
(f as alias)'s POSIX path
(f as text)'s POSIX path
--çµæï¼"/Users/zari/Desktop/abcd.txt"
end repeat
- Finderã§é¸æä¸ã®ãã¡ã¤ã«ã«å¯¾ãã¦æä½ããå ´åããã¶ãä¸è¨ã®ãããªæ¸ãæ¹ãéå½¢ã«ãªãã®ã ã¨æãã
- ãã®éå½¢ã«å¯¾ãã¦ãç確ãªãã¡ã¤ã«åç §ã§ã欲ããæ å ±ãåãåºãã¦ãç®çã®å¦çãå®è¡ãããã¨ã«ãªãã¨æãã
- éå½¢ã ãã§ã¯åããã«ããã®ã§ãå®éã®ãµã³ãã«ã¨ãã¦ãflvããmp4ãå£åãªãã§åãåºãã¹ã¯ãªãããèãã¦ã¿ãã
- çµå±ã®æãæ ¸å¿ã®å¦çã¯ffmpegãå©ç¨ãã¦ãããé¸æä¸ã®ãã¡ã¤ã«æ å ±ããé©åã«å¦çããå¼æ°ã渡ãã©ããã¼ãªã®ã§ããã
property ffmpeg_path : "/opt/local/bin/ffmpeg"
property growlnotify_path : "/usr/local/bin/growlnotify"
tell application "Finder" to set selection_list to selection
repeat with f in selection_list
set file_path to (f as text)'s POSIX path
set non_ext_path to file_path's items 1 thru -5 as text
set in_path to file_path's quoted form
set out_path to (non_ext_path & ".mp4")'s quoted form
set ext to file_path's items -4 thru -1 as text
if ext = ".flv" then
do shell script ffmpeg_path & " -y -i " & in_path & " -vcodec copy -acodec copy " & out_path
do shell script growlnotify_path & " -m " & in_path & " 'å®äº'"
end if
end repeat
Automatorã®å ´åï¼AppleScripté£æºï¼
- Automatorã®ãµã¼ãã¹ã使ã£ã¦ããFinderã§é¸æä¸ã®ãã¡ã¤ã«ã¸ç°¡åã«åå¾ã§ããã
- ãµã¼ãã¹ã®å©ç¹ã¯ãå³ã¯ãªãã¯ãã¦ã³ã³ãã¯ã¹ãã¡ãã¥ã¼ããã¢ã¯ã»ã¹ã§ãããã¨ã§ããã
- ãµã¼ãã¹ã§åãåãããã¡ã¤ã«ã¾ãã¯ãã©ã«ããã¯ããé¸æãããFinderé ç®ãåå¾ãã¢ã¯ã·ã§ã³ã¨åçã ã
- å®è¡ãã¦ã¿ãã¨ãinputå¤æ°ã«ã¯ãé¸æä¸ã®ãã¡ã¤ã«ã¸ã®aliasåç §ã®ãªã¹ãã渡ãããã
- flvããmp4ãåãåºããµã³ãã«ã¯ã以ä¸ã®ããã«ãªã£ãã
- ã»ã¨ãã©åãã§ãå¤æ´ç¹ã¯ä»¥ä¸ã®é¨åã®ã¿ã
- tell application "Finder" to set selection_list to selection ã¯åé¤ã
- å¤æ°selection_listã¯ãinputã«å¤æ´ã
- ããã§ãå³ã¯ãªãã¯ãã¦ãã³ã³ãã¯ã¹ãã¡ãã¥ã¼ã«è¡¨ç¤ºãããããã«ãªã£ãã
Automatorã®å ´åï¼ã·ã§ã«ã¹ã¯ãªããé£æºï¼
- Automatorã¯æè»ã§ãã·ã§ã«ã¹ã¯ãªããã¨é£æºãã¦å®è¡ãããã¨ãã§ããã
- flvããmp4ãåãåºããµã³ãã«ã¯ã以ä¸ã®ããã«ãªã£ãã
- ã¹ã¯ãªã¼ã³ã·ã§ããã§ã¯ä¸é¨ããè¦ããªããã©ãã·ã§ã«ã¹ã¯ãªããã®å ¨ä½ã¯ä»¥ä¸ã®ãããªã³ã¼ãã
for f in "$@" do if [ "${f##*.}" = "flv" ]; then /opt/local/bin/ffmpeg -y -i "$f" -vcodec copy -acodec copy "${f%.*}.mp4" /usr/local/bin/growlnotify -m "$f" 'å®äº' fi done
- èªç¶è¨èªé¢¨ãçã£ãAppleScriptã¯ãå¼±ç¹ã§ããåé·ã丸åºãã
- 対ãã¦ãã·ã§ã«ã¹ã¯ãªããã®ãã以ä¸ãªãç°¡æ½ãã¯æ°æã¡ããã
- å¤æ°å±éã®ã«ã¼ã«ãç¥ããªãã¨ãã¾ãã§æªç¥ã®æå·ãªã®ã ããåãã£ã¦ãã¾ãã°å¯¸åã®ç¡é§ããªãææ³ã«ç¾ãããæãããå¯èªæ§ãè¯ãã
iTunesã»iPhotoã§é¸æä¸ã®ã¢ã¤ãã ã対象ã«ãã
Finderã§é¸æä¸ã®ã¢ã¤ãã ã®æ±ãæ¹ã¯ãã ãã¶ç解ã§ãããããã§ã¯ãiTunesã§é¸æä¸ã®ãã¡ã¤ã«ãæä½ããã«ã¯ã©ããã¹ããï¼
AppleScript
- iTunesã®å ´åã¯ç°¡åã§ãselectionãselection's locationã«ããã ãã§ãæ²ãã¡ã¤ã«ã¸ã®ã¨ã¤ãªã¢ã¹åç §ãªã¹ããåå¾ã§ããã
tell application "iTunes" to set selection_list to selection
--çµæï¼{file track id 11893 of user playlist id 11889 of source id 65 of application "iTunes", file track id 11894 of user playlist id 11889 of source id 65 of application "iTunes"}
tell application "iTunes" to set selection_list to selection's location
--çµæï¼{alias "Macintosh HD:Users:zari:Music:iTunes:iTunes Music:Compilations:BOSSANIMATION:13 ãã¤ãã®è¶³é³ã®ãã©ã¼ã.m4p", alias "Macintosh HD:Users:zari:Music:iTunes:iTunes Music:çæ¨æé:åã®åå - EP:01 åã®åå.m4p"}
- iPhotoã®å ´åãselection's locationã¨ãããããªãããããã§ã¯ãã¡ã ã£ã...ãï¼locationã¨ããå±æ§ãããiPhotoã«ã¯ç»é²ããã¦ããªãï¼
- 調ã¹ã¦ã¿ãã¨ãimage pathã»thumbnail pathããã¹ãåå¾ããå±æ§ã«ãªãããã ã
- æ©éãselection's image pathã¨ãã£ã¦ã¿ããããã¯ãã¨ã©ã¼çºçãï¼å¤æã§ãã¾ãããã¨ï¼
- é¢åã ãã©ãå°éã«ãªã¹ãã®ä¸èº«ãä¸ã¤ãã¤åãåºãã¦å¦çããå¿ è¦ãããããã ã
- image pathã»thumbnail pathã®çµæã¯ãUNIXå½¢å¼ã®ãã¹ããã¹ãã¨ãã¦è¿ããããï¼aliasåç §ã§ã¯ãªãã®ã§æ³¨æãå¿ è¦ï¼
tell application "iPhoto"
set image_path_list to {} set thumbnail_path_list to {} --repeat with i in selection --selectionã§ã¯ã¨ã©ã¼ã«ãªã
repeat with i in selection as list --selection as list ã¨ããå¿ è¦ãã
set image_path_list's end to i's image path
set thumbnail_path_list's end to i's thumbnail path
end repeat
end tell
image_path_list
--çµæï¼{"/Users/zari/Pictures/iPhoto Library/Originals/2010/2010:09:18/DSC_0276.JPG", "/Users/zari/Pictures/iPhoto Library/Modified/2010/2010:09:18/DSC_0277.JPG"}
thumbnail_path_list
--çµæï¼{"/Users/zari/Pictures/iPhoto Library/Data/2010/2010:09:18/DSC_0276.jpg", "/Users/zari/Pictures/iPhoto Library/Data/2010/2010:09:18/DSC_0277.jpg"}
Automatorã®å ´åï¼AppleScripté£æºï¼
- ãµã¼ãã¹ãããã¡ã¤ã«ãã¹ãåå¾ã§ããããªé¯è¦ã«é¥ã£ã¦ãã¾ãã®ã ããå®ã¯ã§ããªãã£ãã
- ãµã¼ãã¹ãããã¡ã¤ã«ãã¹ãåå¾ã§ããã®ã¯ãFinderãå©ç¨ãã¦ããæã ãã®ããã ã
- ã§ã¯ã©ãããããã¨ããã¨ãé¸æãããiTunesãã©ãã¯ãåå¾ãã¢ã¯ã·ã§ã³ã§åå¾ããã
- ãããããé¸æãããiTunesãã©ãã¯ãåå¾ãããå¤ã¯ãiTunesã®ãªãã¸ã§ã¯ããªã¹ãã
{file track id 11893 of user playlist id 11889 of source id 65 of application "iTunes", file track id 11894 of user playlist id 11889 of source id 65 of application "iTunes"}
- ããã§ããæå®ãããFinderé ç®ãåå¾ããç¹ãã¦ã¿ãã¨ãUNIXãã¹å½¢å¼ã®ãªã¹ãã«å¤æãããã
( "/Users/zari/Music/iTunes/iTunes Music/Compilations/BOSSANIMATION/13 \U3084\U3064\U3089\U306e\U8db3\U97f3\U306e\U30cf\U3099\U30e9\U30fc\U30c8\U3099.m4p", "/Users/zari/Music/iTunes/iTunes Music/\U718a\U6728\U674f\U91cc/\U541b\U306e\U540d\U524d - EP/01 \U541b\U306e\U540d\U524d.m4p" )
- ãã®å¾ããAppleScriptãå®è¡ããç¹ããã¨ãaliasåç §å½¢å¼ã®ãªã¹ãã«å¤æãããå¤ãåå¾ã§ããã
{alias "Macintosh HD:Users:zari:Music:iTunes:iTunes Music:Compilations:BOSSANIMATION:13 ãã¤ãã®è¶³é³ã®ãã©ã¼ã.m4p", alias "Macintosh HD:Users:zari:Music:iTunes:iTunes Music:çæ¨æé:åã®åå - EP:01 åã®åå.m4p"}
- ä¸è¨ã¯iTunesã®å ´åã ããiPhotoã®å ´åãå ¨ãåãæé ã§aliasåç §ã®ãªã¹ããåå¾ãããã¨ãåºæ¥ãã
- åãåºæºã§å¸¸ã«aliasåç §ãåå¾ã§ããã®ã§ã¨ã¦ã便å©ã ã
- AppleScriptã ã¨ãã¢ããªã±ã¼ã·ã§ã³ãã¨ã«æ¹æ³ãéã£ã¦ãã¾ãããã®é½åº¦èª¿ã¹ãå¿ è¦ãããã
Automatorã®å ´åï¼ã·ã§ã«ã¹ã¯ãªããé£æºï¼
- ã·ã§ã«ã¹ã¯ãªããã§ã¯ããã«ç°¡æ½ã«ãç®çã¨ããå½¢å¼ã®å¤ãåå¾ã§ããã
- ãé¸æãããiTunesãã©ãã¯ãåå¾ããã¦ãã·ã§ã«ã¹ã¯ãªãããå®è¡ãããã ãã§ãæ¢ã«UNIXå½¢å¼ã®ãã¹ã«å¤æãããå¤ã渡ããã¦ããã
( "/Users/zari/Music/iTunes/iTunes Music/Compilations/BOSSANIMATION/13 \U3084\U3064\U3089\U306e\U8db3\U97f3\U306e\U30cf\U3099\U30e9\U30fc\U30c8\U3099.m4p", "/Users/zari/Music/iTunes/iTunes Music/\U718a\U6728\U674f\U91cc/\U541b\U306e\U540d\U524d - EP/01 \U541b\U306e\U540d\U524d.m4p" )
é¸æä¸ã®ããã¹ãã対象ã«ãã
é¸æä¸ã®ãã¡ã¤ã«ã¨åãããã«ãé¸æä¸ã®ããã¹ãã«å¯¾ãã¦ããæ§ã ãªå¦çãå®è¡ã§ããã¨ä¾¿å©ã§ããã
AppleScript
- ã¢ã¯ãã£ããªã¢ããªã±ã¼ã·ã§ã³ã®é¸æä¸ã®ããã¹ããåå¾ããã«ã¯ãã¡ãã£ã¨å·¥å¤«ãå¿ è¦ãããããªãã
- èªåã®å ´åã¯ãGUIã¹ã¯ãªããã£ã³ã°ã§command-Cãå®è¡ãã¦ãã¯ãªãããã¼ãã®å 容ãåå¾ãã¦ããã
tell application "System Events"
keystroke "c" using command down
delay 0.5
the clipboard as text
end tell
- delay 0.5 ã¯ãã³ãã¼æä½ãå®äºããã¾ã§ã®å¾ æ©æéã
- å¾ æ©æéããªãã¨ãã¯ãªãããã¼ãã¸ãã¼ã¿ã転éãããåã«æ¬¡ã«é²ãã§ãã¾ããã¨ããããäºæ³å¤ã®çµæã«æ··ä¹±ããã
- ä¸è¨ã¹ã¯ãªããã«ã»ãã®ã¡ãã£ã¨è¿½å ããã ãã§ãé¸æä¸ã®ããã¹ããã·ã³ã°ã«ã¯ã©ã¼ãã§å²ãã¹ã¯ãªãããåºæ¥ä¸ããã
tell application "System Events"
keystroke "c" using command down
delay 0.5
set the clipboard to "'" & (the clipboard as text) & "'"
keystroke "v" using command down
end tell
- é¸æä¸ã®ããã¹ããå²ãã¨ããéè¦ã¯çµæ§ããã®ã§ãä¸è¨ä»¥å¤ã«ãã«ãã³ãã¿ã°ãªã©ãç¨æãã¦ããã¨ãå°ããªå¹¸ããæãããããããªãã
Automatorã®å ´åï¼AppleScripté£æºï¼
- Automatorã®ãµã¼ãã¹ããé¸æä¸ã®ããã¹ãæä½ã¯ããªãå¾æãªåéã§ããã
- ã·ã³ã°ã«ã¯ã©ã¼ãã§å²ããµã³ãã«ã¯ãæ ¸å¿é¨åã®ã³ã¼ãã ãã«ãªã£ã¦ãã¾ã£ãã
- ããããå³ã¯ãªãã¯ãã¦ãã³ã³ãã¯ã¹ãã¡ãã¥ã¼ãã辿ããã®ã§ãæä½ãç°¡åã
Automatorã®å ´åï¼ã·ã§ã«ã¹ã¯ãªããé£æºï¼
- ã·ã³ã°ã«ã¯ã©ã¼ãã§å²ããµã³ãã«ã¯ããã¯ãæ ¸å¿é¨åã ãã®ã³ã¼ãã ãã
- ã¨ããã§ãã·ã§ã«ã¹ã¯ãªããã®ããã¹ãæä½ã³ãã³ãã¯ããªãå¼·åã«æã£ã¦ããã
- å²ãã ãã®å¦çã«çµããããã®ã¯å¿ä½ãªãã
- ãã¯ã¼ã¯ããã¼å®è¡æã«ãã®ã¢ã¯ã·ã§ã³ã表示ãããè¨å®ã«ãã¦ã以ä¸ã®ããã«ãã¦ã¿ãã
- ããã¹ããé¸æãã¦ãå®è¡ãã¦ã¿ãã¨...
- ã¢ã¯ã·ã§ã³ã表示ããã¦ãç·¨éãã¦ããå®è¡ã§ããããã«ãªãã®ã ã
- ä¾ãã°ãsedã³ãã³ãã®è¯ã使ããããªãªãã·ã§ã³è¨å®ãããã¤ãç¨æãã¦ããã¨ã便å©ãããããªãã
- ãã¡ãããå ¨ãæ°è¦ã«ã³ãã³ããæ¸ãç´ãã¦ãã¾ã£ã¦ãè¯ãããã¤ãã§é£æºããã¦ãè¯ãã
- GUIç°å¢ã§é¸æä¸ã®ããã¹ãã«å¯¾ããã·ã§ã«ã¹ã¯ãªããã®æ£è¦è¡¨ç¾ã¨ãã¤ããå©ç¨ã§ããã®ã¯å¤§ããã
- ã·ã§ã«ã¹ã¯ãªããããPerlãRubyã¨ãé£æºã§ããã®ã§ãå¯è½æ§ã¯ããã«åºããã
ç確ã«é¸æ対象ãåå¾ãããã¨ã¯ã幸ããªã¹ã¯ãªããç°å¢ã«éããã®ã§ãã£ãã
åèãã¼ã¸
ã·ã§ã«ã¹ã¯ãªããã®ãã¨ã§åãããªãæã«ããã¤ãé ¼ã£ã¦ãã¾ãã®ã以ä¸ã®ãã¼ã¸ãï¼æè¬ã§ãï¼ï¼
- UNIX & Linux ã³ãã³ãã»ã·ã§ã«ã¹ã¯ãªãã ãªãã¡ã¬ã³ã¹
- èªåãåãããªãã¨æãæãããã¤ãå¾¹åºçã«è§£èª¬ããã¦ãã¦ããã®åããæãã«æåãã¦ãã¾ãã