我正在尝试编写一个苹果脚本,用“S0XEYY”顺序命名我的电视节目,其中YY是两位数字。我有以下内容:
tell application "iTunes"
set p to selection
set c to count of p's items
set fixed indexing to true
repeat with i from 1 to c
set t to item i of p
try
set the episode number of t to i
set the episode ID of t to "S" & (text returned of a) & "E" & i
set the season number of t to text returned of a
end try
end repeat
但是,我需要
(a返回的文字)
以及
我
宽度为2,用0填充。我该怎么做呢?
答案 0 :(得分:1)
以下是我的观点:
if i ≤ 9 then
set the episode ID of t to episode ID of t & "0" & i
else
set the episode ID of t to episode ID of t & i
我确信这不是最好的方法,因为它假定不需要超过2个字符,但它是我的最佳解决方案,适用于此应用程序因为电视季节从未(我见过)超过20-30集。