Categories: Misc / DotNet / Java / Coder / Linux / PHP Ask - La ask - La Answer

Script total filesize for checked songs?

27 gigs in iTunes library don't fit into a 20 gig iPod.

Check/uncheck files whenever I feel like changing what music I carry with me. Getting tired of the "not enough room" error then waiting to try again after unchecking more songs.

Is there a script to tell me the total filesize of those songs that are checked in the library?
[352 byte] By [MN_Ham_iPod] at [2007-11-9 14:54:22]
# 1 Re: Script total filesize for checked songs?
Sorry, it only does mega bytes:

tell application "iTunes"
set lib to get a reference to library playlist 1
set tsize to 0
repeat with t from 1 to (count file tracks of lib)
tell file track t of lib
if enabled is true then
try
with timeout of 300 seconds
set tsize to (size) + tsize
end timeout
end try
end if
end tell
end repeat
set tsize to (round tsize / 1024 / 1024 * 100 rounding up) / 100
display dialog "The size of all enabled tracks is " & tsize & "MB" buttons {"OK"} default button 1 giving up after 15
end tell

Copy into Script Editor, Save in home > Library > iTunes > Scripts

Let me know.
Doug Adams at 2007-11-15 17:25:00 >
# 2 Re: Script total filesize for checked songs?
[QUOTE]Originally posted by Doug Adams
[B]Sorry, it only does mega bytes:

It works perfect and I appreciate your efforts. I wasn't expecting a custom solution, turnkey as it were. Above and beyond the call of duty....

Thanks. I'm grateful.

Now if only Apple would make it so that I could check/uncheck only highlighted items in a list, rather than *all* of them in the list via command key click. Or else I'm gonna need an 80gig pod within the year.
MN_Ham_iPod at 2007-11-15 17:26:00 >
# 3 Re: Script total filesize for checked songs?
No problem. And, since you asked...

Check selected tracks:

tell application "iTunes"
if selection is not {} then
set sel to get a reference to selection
repeat with t from 1 to (count items of sel)
if class of item t of sel is file track then
set enabled of item t of sel to true
end if
end repeat
end if
end tell

Uncheck selected tracks:

tell application "iTunes"
if selection is not {} then
set sel to get a reference to selection
repeat with t from 1 to (count items of sel)
if class of item t of sel is file track then
set enabled of item t of sel to false
end if
end repeat
end if
end tell
Doug Adams at 2007-11-15 17:27:09 >
# 4 Re: Script total filesize for checked songs?
[QUOTE]Originally posted by Doug Adams
[B]No problem. And, since you asked...

Thank you again. Much obliged.
MN_Ham_iPod at 2007-11-15 17:28:04 >
[an error occurred while processing this directive]
[an error occurred while processing this directive]