开发者

Setting the width of a variable in applescript

开发者 https://www.devze.com 2022-12-31 15:05 出处:网络
I am trying to write an apple script that sequentially names my TV shows with \"S0XEYY\" where YY is a two digit number. I have the following:

I am trying to write an apple script that sequentially names my TV shows with "S0XEYY" where YY is a two digit number. I have the following:

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开发者_StackOverflow社区 t to text returned of a
            end try
        end repeat

However, I need the

(text returned of a)

as well as

i

to be of width 2, padded with a 0. How do I go about doing this?


Here is how I went about it:

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

which I am sure is not the best way to do it, because it assumes no more then 2 characters are needed, but its the best solution I have, which works for this application because TV seasons never (that I have seen) exceed 20-30 episodes.

0

精彩评论

暂无评论...
验证码 换一张
取 消