Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Watch for a filename length issue in iTunes' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Watch for a filename length issue in iTunes
Authored by: Frederico on Feb 10, '05 01:42:25PM

Unless I misunderstand the OP's problem description, this script will not help, as it only identifies the track name as recorded in iTunes under the 'name' field, whereas the actual file name can be longer (or shorter) depending on both your preferences to have iTunes manage your library and the file type.

E.G., I have several files in my library with the following name format in Finder:

Tangled Up In Blue (live) - Bob Dylan - The Bootleg Series, Vol. 5; Bob Dylan Live 1975 - The Rolling Thunder Revue (Live) - 1975 (1977) (2002) - Rock - iTunes QT Videos.mp4

… and yet iTunes reports the name only as 'Tangled Up In Blue (live)'.

So, if the OP's problem is that actual file name in Finder, the above script will not flag it. It would need to be modified to get the track's location, instead, and count characters less the parent file path, including extension. Isn't at all hard to do (should be less than three lines), especially for the iTunes Scripting Guru who posted this.

If I misunderstand the OP's original problem description, then please disregard this post.

Cheers

Frederico



[ Reply to This | # ]
Watch for a filename length issue in iTunes
Authored by: Frederico on Feb 10, '05 01:53:38PM
This should do it:

property longPlaylist : "_Tracks With Long Names"
tell application "iTunes"
	set thisPlaylist to view of front browser window
	if class of thisPlaylist is not library playlist then
		set z to true
		repeat with aTrack in (every track of thisPlaylist)
			set fileName to ((get aTrack's location) as text)
			set fileName to characters (-(offset of ":" in (reverse of every character of fileName as text)) + 1) thru -1 of fileName as text
			if (length of fileName) > 250 then
				if not (exists playlist longPlaylist) then
					make playlist with properties {name:longPlaylist}
				else if z then
					try
						delete every track of playlist longPlaylist
						set z to false
					end try
				end if
				duplicate (aTrack) to playlist longPlaylist
			end if
			
		end repeat
	end if
end tell


[ Reply to This | # ]
Watch for a filename length issue in iTunes
Authored by: DougAdams on Feb 10, '05 03:43:01PM

Of course. I scripted hastily!

Cheers.

---
Doug's AppleScripts for iTunes
http://www.malcolmadams.com/itunes/



[ Reply to This | # ]
Watch for a filename length issue in iTunes
Authored by: drewk on Feb 11, '05 01:25:32PM
Since the poster described the behavior of iTunes adding characters that then cause the filename to cross the 250 character limit, this line:

       if (length of fileName) > 250
needs to be:

      if (length of fileName) > (250-5)
to allow for the suffix on the name. Assumably 99,999 songs is enough ;->

drewk

[ Reply to This | # ]
Watch for a filename length issue in iTunes
Authored by: Frederico on Feb 19, '05 11:16:04PM

If you reread the OP, you'll see he notes a 255 character limit, standard for HFS+ under X, hence the >250 (251) character flag, which allows for the addition of up to four more characters safely.



[ Reply to This | # ]