I have the AppleScri开发者_StackOverflow中文版pt code shown below which tells iTunes to convert the track from the selection. I was wondering how I would limit the length of the track that will be converted?
tell application "iTunes"
set theFiles to the selection
repeat with theTrack in theFiles
with timeout of 120 seconds
set theSecondTrack to first item of (convert theTrack)
If you wanted to to limit the length of the converted track via the iTunes GUI, you would set the "Stop Time" of the original track in Get Info>Options. The corresponding AppleScript property for this is finish
(of the track
class).
So the steps in your repeat loop should be:
- Get the original stop time of the track (usually this will just be the full duration of the track)
- Set the stop time to your limit length (in seconds)
- Convert the track
- Set the stop time back to what it was at 1.
Example 60-sec limit:
repeat with theTrack in theFiles
tell theTrack
set originalFin to finish
set finish to 60
-- Track conversion code goes here
set finish to originalFin
end tell
end repeat
精彩评论