0

我制作了一个自动化工作流程,可以将歌曲添加到我的 iTunes 库中,并通过艺术家姓名、专辑名称和歌曲名称设置他们的信息。然而,当我导入它们时,这些轨道是无盖的,所以我一直在寻找自动添加艺术品的方法。其中一种方法是使用 iTunes “获取专辑插图”。这样做的问题是,即使它提供了它,它通常也不能提供非常好的艺术品。

我决定下载我没有艺术作品的歌曲的艺术作品,这些歌曲存储在我的“下载”文件夹中。我传递给我的input脚本的是 .jpg 文件,我想将它作为艺术品添加到歌曲中。问题是每当我运行这个脚本时,它都会说它不能将别名文件变成文件类型。错误信息如下:

无法将别名“Macintosh HD:Users:Nilay:Downloads:Avicii - True - Hey Brother.jpg”转换为类型文件。

没有理由找不到该文件,因为我使用 Automator “Filter Finder Items”找到了该文件,所以我知道它传递了正确的文件。

我试图传递文件的文本而不是实际的文件,但这仍然导致相同的消息。前几条评论是我试图解决此错误消息的几种方法,但可惜,没有一个奏效。

我想知道是否有人知道如何解决此错误消息或其他方式,我可以将自定义艺术品添加到歌曲中,而无需手动转到 iTunes -> 选择歌曲 -> 获取信息 -> 艺术品 -> 添加艺术品。如果有人可以解释如何使用 AppleScript 或 Workflow 自动执行此操作,这也是可行的。谢谢!!!

on run {input, parameters}

    --set jpegFilename to input
    --set jpegFilename to "/path/to/some/artwork.jpg"
    --set jpegFile to (POSIX file jpegFilename)
    --set jpegFile to (jpegFilename as POSIX file)
    --tell application "System Events" to set jpegFile to (input as POSIX file)
    set jpegFile to input

    tell application "Image Events"
        set myImage to open (jpegFile as file)
        -- the below line needs HFS syntax pathname, eg: MyComputer:Users:liquidx:
        -- save myImage as PICT in (file ":path:to:some:temporary.pict")
        save myImage as PICT in (POSIX file jpegFile)
        close myImage
    end tell

    tell application "iTunes"
        set myTrack to current track
        set artworkCount to count of artwork of myTrack
        -- the below line needs HFS syntax pathname, eg: MyComputer:Users:liquidx:
        -- set myArt to read (file ":path:to:some:temporary.pict") from 513 as picture
        set myArt to read (POSIX file jpegFile) from 513 as picture
        if artworkCount > 0 then
            set data of artwork (artworkCount + 1) of current track to myArt
        else
            set data of artwork 1 of current track to myArt
        end if
    end tell

    tell application "Image Events"
        -- delete (file ":path:to:some:temporary.pict")
        delete (POSIX file jpegFile)
    end tell

end run
4

1 回答 1

0

input是一个别名说明符列表,首先你需要一个重复循环

repeat with jpegFile in input

或获取列表的第一项

set jpegFile to item 1 of input

然后open命令Image Events无论如何都需要一个别名说明符,因此不需要任何强制。

set myImage to open jpegFile
于 2016-02-29T05:58:42.553 回答