gpt4 book ai didi

python - 使用正则表达式(或类似的)通过脚本更改 itunes 中的歌曲名称(或其他标签)

转载 作者:行者123 更新时间:2023-12-01 05:37:21 25 4
gpt4 key购买 nike

所以我遇到了脚本问题(并且找不到特定的应用程序来与 itunes 结合执行此操作)。

我可以对 Python 中的任何脚本执行类似的操作,假设我有歌曲标题:

我的心跳 - 原创混音

我想将其更改为我的心跳(原始混音)

在Python中我会:

string = 'Beat of my heart - original mix'
location = string.index(' - ')
fixed_string = string[,location] + '(' + string[location+3,] + ')'

简单吧?但我想在 iTunes(在 Mac 上)中对我已标记为此类的轨道进行批处理

有什么建议吗?

谢谢

最佳答案

尝试:

tell application "iTunes"
set myTracks to get selection
repeat with aTrack in myTracks
set trackName to aTrack's name
set newTrackName to do shell script "sed 's/ - \\(.*\\)/ (\\1)/' <<< " & quoted form of trackName
if newTrackName ≠ trackName then set aTrack's name to newTrackName
end repeat
end tell

关于python - 使用正则表达式(或类似的)通过脚本更改 itunes 中的歌曲名称(或其他标签),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18601725/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com