我尝试做什么:
当我在我的一个文本编辑器(TextEdit,Byword,FoldingText)中时,我希望AppleScript显示文件路径.
我想要求最前面的窗口应用程序让我的应用程序名称很好,很容易,然后我可以在下一步请求POSIX路径.
问题:
脚本已经99%了,但我遗漏了一些东西.当我尝试使用activeApp它的变量不起作用,我得到这个错误:
Error Number:System Events got an error: Can’t get application {"TextEdit"}.
-1728
Run Code Online (Sandbox Code Playgroud)
这是脚本:
tell application "System Events"
set activeApp to name of application processes whose frontmost is true
--This doesn't work either:
--do shell script "php -r 'echo urldecode(\"" & activeApp & "\");'"
tell application activeApp
set myPath to POSIX path of (get file of front document)
end tell
display dialog myPath
end tell
Run Code Online (Sandbox Code Playgroud)
如果我activeApp与"TextEdit"一切工作交换.帮助将不胜感激.
也许这里有一些帮助:使用Applescript从应用程序名称获取进程名称,反之亦然
首先,这是我第一次使用shell脚本.我只有HTML和CSS的经验:]
我想要做的是设置一个简单的文件夹结构,并在对话框中提示用户设置根文件夹的名称.我将通过OS X服务或Keyboard Maestro热键触发此shell脚本.
这是我到目前为止所提出的:
#!/bin/sh
echo -n "Enter the project name:"
read -e NAME
mkdir -p ~/Desktop/$NAME
mkdir -p ~/Desktop/$NAME/subfolder1
mkdir -p ~/Desktop/$NAME/subfolder2
Run Code Online (Sandbox Code Playgroud)
显然有一些错误 - 变量不会被传递,并且不会创建根文件夹.我还读到我应该使用"对话框"来询问输入,但我无法写出有效的东西.
非常感谢您的帮助.谢谢.
使用时出现以下错误grunt compass:
"您必须从项目目录中编译单个样式表."
我用3种不同的方式尝试了它.更多下面.
我的文件夹结构:
test \
Gruntfile.js
package.json
\ node_modules \
\ _src \ (this is the root folder of my Jekyll site)
\ config.rb
\ index.html
\ static/
\ _sass \
\ css \
\ images \
\ js \
Run Code Online (Sandbox Code Playgroud)
一切正常,无需使用grunt和使用/_src/config.rb:
#project_path = "_src/"
http_path = "/"
css_dir = "css"
css_path = "static/" + css_dir
sass_dir = "_sass"
sass_path = "static/" + sass_dir
images_dir = "images"
images_path = "static/" …Run Code Online (Sandbox Code Playgroud) 我尝试一起破解Keyboard Maestro快捷方式,以便为我提供文件的URL(就像“路径查找器”的输出一样)。
到目前为止,我用下面的AppleScript和替代空间与%20:
tell application "Finder"
set sel to the selection as text
set the clipboard to POSIX path of sel
end tell
Run Code Online (Sandbox Code Playgroud)
然后我简单地追加file://localhost/。
问题是涉及特殊字符时,例如,我在桌面上有以下文件夹:
我的输出: file://localhost//Users/patte/Desktop/#%20Old%20files
正确的输出应转换哈希值: file://localhost/Users/patte/Desktop/%23%20Old%20files
使用AppleScript或Shell脚本的解决方案将是很棒的,因为我有能力将其合并。我也尝试过,set the clipboard to URL of the first item of (get the selection)但这对我没有用-也许我做错了。
另一个选择是对特殊字符进行编码的脚本-我也可以使用该脚本,但是我不确定将什么转换成什么-否则我会寻找它。