标签: applescript

applescript将文件夹复制到Xcode中?

我在使用AppleScript将文件夹复制到XCode项目时遇到了一些麻烦.没有Applescript我将文件夹拖入Xcode.

我使用了类似的Applescript处理程序,如下所示,使用"wrapper.library"将库复制到XCode中作为文件类型.下面我使用"wrapper.folder"尝试将文件夹复制到XCode中,但它无法正常工作.

    on addFolder(fname, fpath)
  tell application "Xcode"
   tell project "Unity-iPhone"
    set my_targets to targets
    set s_target to item 1 of my_targets
    set compile_phase to compile sources phase of s_target
    set link_phase to get link binary with libraries phase of s_target
    tell root group
     set a to make new file reference with properties {full path:fpath & fname, name:fname, file type:"wrapper.folder"}
     add a to link_phase
    end tell
   end tell
  end tell
    end addFolder
Run Code Online (Sandbox Code Playgroud)

有没有人对我遗失的内容或如何编写Applescript以将文件夹复制到XCode有任何想法?

iphone xcode applescript

9
推荐指数
1
解决办法
1610
查看次数

AppleScript:如何检查某些内容是目录还是文件

更新:解决方案如下


假设您有Finder中所选项目的列表.假设有一些文件,文件夹,各种捆绑包,甚至包含在选择中的一些应用程序.

现在说你只想要那些(在UNIX术语中)目录的项目.也就是说,你只需要cd在终端中可以使用的物品.

您可以检查每个项目的kind属性,看它是否等于"文件夹",但这对应用程序包或其他包/包不起作用,尽管它们实际上是"文件夹"(目录)

如果项目是实际文件对象(而不是别名),则可以检查每个项目的class属性...除了并不总是有效之外,因为bundle现在是"文档文件"实例,而应用程序是"应用程序文件"实例.

如果你只有一个别名列表而不是实际的文件对象,那就更糟了,因为你无法检查class属性; 它总是只会说"别名".

我能想到的唯一解决方案是获取每个项目的POSIX路径,并查看它是否有正斜杠,或者将其路径发送到用不同语言编写的脚本,这可以检查某个目录是否是某个目录或不.

这两个想法对我来说都很疯狂.检查尾随斜杠是非常hacky和脆弱的,并将所有内容提供给不同的脚本是完全矫枉过正的.


更新: Asmus建议下面看起来确实是唯一一个很好的解决方案,因为似乎AppleScript无法自行解决这个问题:

do shell script "file -b " & filePosixPath
Run Code Online (Sandbox Code Playgroud)

这将返回文件夹,包,应用程序,软件包等的字符串"目录".
但请注意(!)对于磁盘,它返回"粘性目录".

这是一个非常好用的通用函数

on isDirectory(someItem) -- someItem is a file reference
    set filePosixPath to quoted form of (POSIX path of (someItem as alias))
    set fileType to (do shell script "file -b " & filePosixPath)
    if fileType ends with "directory" then return true
    return false
end isDirectory
Run Code Online (Sandbox Code Playgroud)

applescript

9
推荐指数
1
解决办法
7489
查看次数

使用Applescript在iTunes中获取流媒体曲目的歌曲名称

当此曲目是收音机时,如何在iTunes中获取当前曲目的歌曲名称?

我的意思是出现在收音机名称正下方的字符串:)

在此输入图像描述

在下面查询它的名字给了我radio(Trance Channel - DIGGITALLY IMPORTED - we can't define it!)的名字但不是歌曲的名字

tell application "iTunes"
    set thisTrack to current track
    set trackName to the name of thisTrack
    set trackTime to thisTrack's time
end tell
Run Code Online (Sandbox Code Playgroud)

这是预期的,因为我的库中的信息是: 在此输入图像描述 但有没有办法专门处理这些流媒体曲目?并像第一张图片中的iTunes一样正确获取他们的信息?我知道当前的音轨是一个收音机,因为它的时间将是,missing value而不是形式,MM:SS如果这有点帮助.

这可能吗?

macos applescript itunes

9
推荐指数
1
解决办法
2686
查看次数

将AppleScript中的Finder当前目录存储为应用程序

我试图制作一个AppleScript,它应该从Finder读取当前目录并在其上运行shell命令.如果我在Finder中导航到所需的文件夹并从AppleScript编辑器运行脚本它可以工作,但是当我保存脚本并将其拖到Finder工具栏时,currentDir被设置为脚本文件的文件夹(我的用户目录).这是我的脚本:

tell application "Finder"
    set currentDir to POSIX path of ((container of (path to me)) as text)
end tell
tell application "Terminal"
    do script "cd " & currentDir
    do script "<operation goes here>"
end tell
Run Code Online (Sandbox Code Playgroud)

使用工具栏快捷方式时,如何激活目录?第二,有没有办法在后台运行shell命令,而无需打开(显示)终端窗口?

applescript finder

9
推荐指数
2
解决办法
1万
查看次数

在Yosemite上使用JavaScript for Automation列出文件夹中的所有文件

我正在尝试将一些旧的Applescript移植到新的JavaScript语法中.

事情似乎非常直接,所以:

tell application "System Events" to keystroke "t" using command down
Run Code Online (Sandbox Code Playgroud)

成为:

System = Application('System Events');
System.keystroke("t", {using: "command down"})
Run Code Online (Sandbox Code Playgroud)

但是我不能为我的生活找出如何列出特定位置的文件.在AppleScript中,要返回目录中的文件列表/usr,您可以:

tell application "System Events" to set fileList to name of items in folder "/usr"
-- > {"bin", "include", "lib", "libexec", "local", "sbin", "share", "standalone", "X11"}
Run Code Online (Sandbox Code Playgroud)

但是我不能为我的生活弄清楚如何在Javascript中做到这一点.

System = Application('System Events')
myPath = Path("/usr")

fileList = System.items(myPath) 
-- > message not understood

fileList = System.folder(myPath)
-- > message not understood

fileList = System.diskItems(myPath)
-- > []

fileList …
Run Code Online (Sandbox Code Playgroud)

javascript applescript automation osx-yosemite javascript-automation

9
推荐指数
2
解决办法
4388
查看次数

Emacs与XCode交谈

我在我的mac上使用emacs在Xcode中编程.它在大多数情况下都非常有效.我双击xcode中的文件,然后在现有的emacs窗口中将其拉出来.我编译,并获得语法错误,双击,它们出现在活动的emacs窗口中.大.

这是与emacs交谈的所有XCode.有没有人知道如何让emacs与XCode交谈?例如,我希望能够在emacs中设置断点并让gdb的XCode版本确认它.

debugging emacs xcode applescript elisp

8
推荐指数
1
解决办法
1168
查看次数

AppleScript以最前面的应用程序为目标

我想编写鼠标按钮来显示/隐藏Finder.我编写了以下AppleScript并将其绑定到我的鼠标按钮:

tell application "System Events"
    --When this script is run,
    --  the frontmost application will be this script itself
    --Get the name of this script as it is running and hide it,
    --  so that the previous frontmost application is in front again
    set theName to name of the first process whose frontmost is true
    set visible of process theName to false

    set theName to name of the first process whose frontmost is true
end tell

if theName is "Finder" …
Run Code Online (Sandbox Code Playgroud)

macos applescript

8
推荐指数
1
解决办法
6844
查看次数

使用AppleScript退出应用程序

每当我尝试使用AppleScript退出应用程序时,都会出现以下错误

发生了类型为-9874的错误.

我正在使用的AppleScript命令是

tell application "app_name"
    quit
end tell
Run Code Online (Sandbox Code Playgroud)

有人可以帮帮我吗?

macos applescript exit

8
推荐指数
1
解决办法
3万
查看次数

Apple脚本:如何将html内容复制到剪贴板?

我知道如何将纯文本复制到剪贴板:

oascript -e 'set the clipboard to "plain text"'
Run Code Online (Sandbox Code Playgroud)

但问题是如何将html内容复制到剪贴板?例如,如何将以下html内容复制到剪贴板:

<b>bold text</b>
Run Code Online (Sandbox Code Playgroud)

当我将它粘贴到TextEdit中时,我得到粗体文本?

我在这里先向您的帮助表示感谢!


我找到了一个中间解决方案:

echo "<b>bold text</b>" | textutil -stdin -stdout -format html -convert rtf | pbcopy
Run Code Online (Sandbox Code Playgroud)

到目前为止这很好,但不幸的是我发现它不适用于图像标记:

echo "<img src=\"https://www.google.com/images/srpr/logo3w.png\">" | textutil -stdin -stdout -format html -convert rtf | pbcopy
Run Code Online (Sandbox Code Playgroud)

这不能完成我想要的工作,所以有人知道原因吗?
谢谢!


我找到了一个有效的解决方案并将其发布在下面:)

html macos applescript rtf

8
推荐指数
2
解决办法
3758
查看次数

从csv文件填充iTunes播放列表

任何人都可以提供一种方法来填充我的播放列表与csv文件/文本文件中的歌曲格式如下:歌曲标题,艺术家?我可以单独为标题做,但不能指定它必须有一定的艺术家.

编辑:以下是我如何通过标题获取它们的示例:

set TheFile to read file "Macintosh HD:Applications:Automator stuff:01b iTunes Scripts:SongList.txt"
tell application "iTunes"
    set thePlaylist to playlist "SongList"
    try
        delete every track of thePlaylist
    end try
    set MySongs to paragraphs of (TheFile) -- read artist names (separated by newlines) from the file
    repeat with AnItem in MySongs -- get all tracks from each artist
        set AnItem to (contents of AnItem)
        if AnItem is not "" then try -- don't bother with empty names
            set MyTracks to (location of …
Run Code Online (Sandbox Code Playgroud)

applescript itunes

8
推荐指数
1
解决办法
152
查看次数