나는 Applescript가 서비스로 저장했다고 생각한다.
( "서비스 받기를 선택했습니다. files or folders ...에서 Finder ")
on run {input, parameters}
set basePath to "users/username/folder/"
set baseURL to "http://localhost"
repeat with i in input
tell application "Safari"
if not (exists (document 1)) then
--
-- Safari is *Not* Opened, Call Open New Window Function, Go To Preferred Page
-- and Activate Safari to Enable Scripting
--
tell application "Safari" to activate
my open_new_window()
--
-- Set Safari Location to Preferred Page
--
set theFileName to POSIX path of i
set thePath to text (length of basePath+1) thru -1 of theFileName
set the URL of document 1 to baseURL & thePath
else
--
-- Safari is Opened, Bring it To Front and Open New Tab w/Preferred Page
--
if (exists (URL of document 1)) then
my open_new_tab()
end if
--
-- and Activate Safari to Enable Scripting
--
tell application "Safari" to activate
--
-- Set Safari Location to Preferred Page
--
set theFileName to POSIX path of i
set thePath to text (length of basePath+1) thru -1 of theFileName
set the URL of document 1 to baseURL & thePath
end if
end tell
end repeat
return input
end run
--
-- Open New Window Function
--
on open_new_window()
tell application "Safari" to activate
tell application "System Events"
tell process "Safari"
click menu item "New Window" of menu "File" of menu bar 1
end tell
end tell
end open_new_window
--
-- Open New Tab Function
--
on open_new_tab()
tell application "Safari" to activate
tell application "System Events"
tell process "Safari"
click menu item "New Tab" of menu "File" of menu bar 1
end tell
end tell
end open_new_tab
몇 가지 출처에서 함께 자르다!