如何使 link 在桌面上或与服务停靠只需按一个右键所有在 automator 中执行的 applescript
how make link on desktop or in dock with a service just press a right button all that in an applescript executed in automator
以下脚本将被放置在 automator 中的服务创建中。
从而打开 Automator 和 select 新服务。对于文件和文件夹 link 它们放在桌面上,只需将应用程序放在 Dock 中(你有下面的脚本,你可以修改所有你想要的。
在 automator select 实用程序的左侧,双击执行 applescript 脚本。在右侧你看到 window 打开,在“服务收到 select”项上你选择“文件和文件夹”。
现在下面在window"Execute an Applescript "里面
" 在 运行 {输入,参数}"
你可以把脚本放在下面
on run {input, parameters}
set input to POSIX path of input
set fich to POSIX path of input
set ft to {}
set fold to {}
set sn to {}
set Nm to {}
set {file type:ft} to info for POSIX path of fich
if ft is not "APPL" then
set input to input
set vhdoudmg to input as Unicode text
set input to POSIX path of vhdoudmg
set sn to ""
try
set {name:Nm} to info for file vhdoudmg
end try
if sn is "" then
set lelien to "/Users/username/Desktop/
" & Nm
else
set lelien to "/Users/username/Desktop/
" & sn
end if
set vhdoudmg to do shell script "ln -s -v " & quoted form of input & " " & quoted form of lelien
else
set Reponse to display dialog " Choose to create the symbolic link on the Desktop or Application in the Dock " & return buttons {" The link on the Desktop ", " Application in the Dock "}
set Choix to button returned of Reponse
if " Application in the Dock " is in Choix then
try
set theFile to POSIX path of input
end try
try
tell application "Dock" to quit
end try
do shell script "defaults write com.apple.dock persistent-apps -array-add '<dict><key>tile-data</key><dict><key>file-data</key><dict><key>_CFURLString</k ey><string>" & theFile & "</string><key>_CFURLStringType</key><integer>0</integer></dict></dict></dict>' "
try
tell application "Dock" to activate
end try
else
set input to POSIX path of input
set vhdoudmg to input as Unicode text
set input to POSIX path of vhdoudmg
set fich to do shell script "echo " & input
try
set {name:Nm} to info for file vhdoudmg
end try
set lelien to "/Users/username/Desktop/" & Nm
set vhdoudmg to do shell script "ln -s -v " & quoted form of input & " " & quoted form of lelien
end if
end if
return input
end run
现在您可以将此工作流放在 /Users/yourname/Library/Services 中,当您右击鼠标按钮时,如果您在“服务”的上下文菜单中进行选择,您可以看到此脚本的名称(名称你会在创作过程中给它的。)
从而打开 Automator 和 select 新服务。对于文件和文件夹 link 它们放在桌面上,只需将应用程序放在 Dock 中(你有下面的脚本,你可以修改所有你想要的。
晚上好,更短但同样有效的脚本。
on run {input, parameters}
set input to POSIX path of input
set fich to POSIX path of input
set ft to {}
set Nm to {}
set {name:Nm,file type:ft} to info for POSIX path of fich
set input to input
set vhdoudmg to input as Unicode text
set input to POSIX path of vhdoudmg
set lelien to "/Users/username/Desktop/" & Nm
if ft is not "APPL" then
set vhdoudmg to do shell script "ln -s -v " & quoted form of input & " " & quoted form of lelien
else
set Reponse to display dialog " Choose to create the symbolic link on the Desktop or Application in the Dock " & return buttons {" The link on the Desktop ", " Application in the Dock "}
set Choix to button returned of Reponse
if " Application in the Dock " is in Choix then
try
set theFile to POSIX path of input
end try
try
tell application "Dock" to quit
end try
do shell script "defaults write com.apple.dock persistent-apps -array-add '<dict><key>tile-data</key><dict><key>file-data</key><dict><key>_CFURLString</key><string>" & theFile & "</string><key>_CFURLStringType</key><integer>0</integer></dict></dict></dict>'"
try
tell application "Dock" to activate
end try
else
set vhdoudmg to do shell script "ln -s -v " & quoted form of input & " " & quoted form of lelien
end if
end if
return input
end run
以下脚本将被放置在 automator 中的服务创建中。
从而打开 Automator 和 select 新服务。对于文件和文件夹 link 它们放在桌面上,只需将应用程序放在 Dock 中(你有下面的脚本,你可以修改所有你想要的。
在 automator select 实用程序的左侧,双击执行 applescript 脚本。在右侧你看到 window 打开,在“服务收到 select”项上你选择“文件和文件夹”。
现在下面在window"Execute an Applescript "里面
" 在 运行 {输入,参数}"
你可以把脚本放在下面
on run {input, parameters}
set input to POSIX path of input
set fich to POSIX path of input
set ft to {}
set fold to {}
set sn to {}
set Nm to {}
set {file type:ft} to info for POSIX path of fich
if ft is not "APPL" then
set input to input
set vhdoudmg to input as Unicode text
set input to POSIX path of vhdoudmg
set sn to ""
try
set {name:Nm} to info for file vhdoudmg
end try
if sn is "" then
set lelien to "/Users/username/Desktop/
" & Nm
else
set lelien to "/Users/username/Desktop/
" & sn
end if
set vhdoudmg to do shell script "ln -s -v " & quoted form of input & " " & quoted form of lelien
else
set Reponse to display dialog " Choose to create the symbolic link on the Desktop or Application in the Dock " & return buttons {" The link on the Desktop ", " Application in the Dock "}
set Choix to button returned of Reponse
if " Application in the Dock " is in Choix then
try
set theFile to POSIX path of input
end try
try
tell application "Dock" to quit
end try
do shell script "defaults write com.apple.dock persistent-apps -array-add '<dict><key>tile-data</key><dict><key>file-data</key><dict><key>_CFURLString</k ey><string>" & theFile & "</string><key>_CFURLStringType</key><integer>0</integer></dict></dict></dict>' "
try
tell application "Dock" to activate
end try
else
set input to POSIX path of input
set vhdoudmg to input as Unicode text
set input to POSIX path of vhdoudmg
set fich to do shell script "echo " & input
try
set {name:Nm} to info for file vhdoudmg
end try
set lelien to "/Users/username/Desktop/" & Nm
set vhdoudmg to do shell script "ln -s -v " & quoted form of input & " " & quoted form of lelien
end if
end if
return input
end run
现在您可以将此工作流放在 /Users/yourname/Library/Services 中,当您右击鼠标按钮时,如果您在“服务”的上下文菜单中进行选择,您可以看到此脚本的名称(名称你会在创作过程中给它的。)
从而打开 Automator 和 select 新服务。对于文件和文件夹 link 它们放在桌面上,只需将应用程序放在 Dock 中(你有下面的脚本,你可以修改所有你想要的。
晚上好,更短但同样有效的脚本。
on run {input, parameters}
set input to POSIX path of input
set fich to POSIX path of input
set ft to {}
set Nm to {}
set {name:Nm,file type:ft} to info for POSIX path of fich
set input to input
set vhdoudmg to input as Unicode text
set input to POSIX path of vhdoudmg
set lelien to "/Users/username/Desktop/" & Nm
if ft is not "APPL" then
set vhdoudmg to do shell script "ln -s -v " & quoted form of input & " " & quoted form of lelien
else
set Reponse to display dialog " Choose to create the symbolic link on the Desktop or Application in the Dock " & return buttons {" The link on the Desktop ", " Application in the Dock "}
set Choix to button returned of Reponse
if " Application in the Dock " is in Choix then
try
set theFile to POSIX path of input
end try
try
tell application "Dock" to quit
end try
do shell script "defaults write com.apple.dock persistent-apps -array-add '<dict><key>tile-data</key><dict><key>file-data</key><dict><key>_CFURLString</key><string>" & theFile & "</string><key>_CFURLStringType</key><integer>0</integer></dict></dict></dict>'"
try
tell application "Dock" to activate
end try
else
set vhdoudmg to do shell script "ln -s -v " & quoted form of input & " " & quoted form of lelien
end if
end if
return input
end run