Become a member of the iLounge Forums. Register Now!
To start viewing messages, select the forum that you want to visit from the selection below.
If this is your first visit, be sure to check out the Forum FAQ and Forum Policy.

Topic: Trying to consolidate library - filename too long

Closed Thread Thread Tools Topic Search
 
Old 07-10-2011, 07:20 AM
#1
 
Freshman Lounger
 
Join Date: Jul 2011
Posts: 12
Trying to consolidate library - filename too long

I originally managed files etc myself, but now want itunes to do it. I followed instructions that I found here and elsewhere and selected "keep organised" and "copy files" and then consolidated my library, but about a third of the way through it stopped saying a filename was too long.

I have been poking around and found a few long files, but how do I rename them in itunes? And how can I be sure that I have fixed the right one(s)?

And once done, can I be sure that itunes won't create filenames too long (assuming a long artist/name/album??)
Olmy is offline  

Join the iLounge Community and the ad above will disappear.

Old 07-10-2011, 12:50 PM
#2
 
Veteran Lounger
 
S2_Mac's Avatar
 
Join Date: Oct 2006
Location: About 3 feet in front of the monitor
Posts: 4,878

I have been poking around and found a few long files, but how do I rename them in itunes? And how can I be sure that I have fixed the right one(s)?

I know this is a very frustrating situation; it's been around for years without a fix from Apple, which makes me think it's not a trivial problem for them to solve. But it's worth working through, since letting iTunes manage your files really does have benefits...especially when it comes to moving your music files to another drive or onto a new computer.

You won't use iTunes to rename these files, you'll have to use Explorer. (And yes, that will break the iTunes "link" to those files. Here's the More Info....)

This problem usually has up to three causes: the file name itself may be too long (the Sufjan Stevens track "To The Workers of The Rock River Valley Region, I have an idea concerning your predicament, and it involves an inner tube, bath mats, and 21 able-bodied men.mp3", for instance ;-); or the file's path may be too long (the combined names of all folders containing a file also has a length limit); also, some folks suspect that non-ASCII characters in a name (Beyonc) may trigger this error. When iTunes is already managing your files, it can change file and folder names, but not while you're consolidating -- the process is for iTunes to first move the file into its folder structure, and then rename the file to match the track name (truncating any names that are too long). So it's a bit of a Catch-22....

There is no easy fix (other than not using Windows ;-). There are a number of things to try. First, you might want to try the "Consolidation Fix" script to spot the too-long name(s). Here's a download link for this small file. I'm not a Windows guy, so I'm not exactly sure how you run it...it's a Javascript that uses the iTunes .COM interface. According to the author: "It runs with the Windows Script Host. If it doesn't launch when you double-click the js file, then you can try extracting it, right-click, and select "Open With : Microsoft (R) Windows Based Script Host". If that option is not available to you, then you can try running "wscript ConsolidationFix.js" from the command line where you extracted the file." (N.B. You want to have iTunes open when you run it.)

For some folks this script works just fine; others get no joy at all. After it flags a file for having a too-long name, it's up to you to locate the file, move it to a shorter file path or give it a shorter file name, and then re-link the file to iTunes (do this by attempting to Get Info on the track; when iTunes complains that it can't locate the file, click the Locate button and use the File dialog to re-link it).

The most effective manual method of locating your too-long file names/paths is to take advantage of the scheme iTunes uses for copying files during Consolidation. iTunes copies files in the order in which they were added to iTunes, oldest first. (So, the first file you ever added to your library will be the first file iTunes attempts to copy during a Consolidation; the most-recently added file will be the last file iTunes attempts to copy.) One method for exploiting this is outlined in this post at the Apple boards; look for the first response from Katrina.

Another way to use iTunes' copy order to deal with too-long names is to read through the iTunes Library.xml file. As with the Consolidation copy order, the XML file lists files in the order in which they were added to iTunes -- the first file you added to this library will be the first file listed in the XML file; the last file you added will be at the end of the XML file's listing of files. (The XML file also lists all your playlists, so the end of the library listing is not the end of the file.) If you've got a competent text editor -- I'm not sure how well WordPad or NotePad do with huge text files -- the method outlined in this blog post may work well for you -- skip the article, look for the follow-up bit labelled "Update".

[ FWIW, here's a method of my own devising. Since the days of iTunes 9, it's been possible to Consolidate small groups of files. (In the old days, you had to consolidate everything, all at once.) Sort your "Music" listing by Date Added (you may have to add a Date Added column to your iTunes "Music" listing), date ascending -- oldest files at the top.

Now, select the first few hundred tracks and then choose the File menu->"New playlist from selection" command; name this new playlist "Consolidate group 1". Now select the next few hundred tracks, use the "New playlist from selection" command, name this playlist "Consolidate group 2". Wash, rinse, repeat, until all tracks are in these playlists.

Now display the Group 1 playlist. Select all its tracks (Ctrl-A) and then right-click on the selection for "Consolidate files..." (Wups, should have mentioned this -- make sure you've got your destination "iTunes Media" folder set in iTunes prefs before you do this, along with having the "Copy files to iTunes Media" and "Keep iTunes Media organized" prefs set.) iTunes will now attempt to consolidate that group of files. If that group consolidates without problems, great -- delete the playlist by selecting its name and hitting Delete key (this will remove the playlist, but not the tracks),and move on to the next "Consolidate group" playlist.

But if that playlists contains a "problem" file, take this step: select half the tracks in the playlist, and create a new playlist from them ("Consolidate group 1A"), then go back to that original playlist and delete the selected tracks. Try consolidating the original playlist again. If it works, great -- the problem file is in the Group 1A list; split that list in half, try again. Wash, rinse, repeat..... (This is the old "binary list" method that's been around forever; if you have lots of too-long filenames it could get tedious, but it will certainly get the job done.)]

= = = = = = = = = = = = = = = = = = = = = = =

No matter what method you use, remember that resolving the too-long issue will require you to change the file name or file path in Windows, and then either re-link the file in iTunes (preserving all iTunes metadata like play counts, ratings, the playlists that file belongs in, etc.), or just delete the track from iTunes (deleting its metadata as well) and re-add the file(s) later. Most folks seem to have only a few files that muck things up, so this isn't too odious a burden.....

Another troubleshooting step I overlooked -- make sure your destination folder isn't causing the problem. If the destination folder (the folder you've set to be your "iTunes Media" folder) has a long filepath name, that could be your problem right there. (If you're using XP and are consolidating into the "iTunes" folder in your user account's My Music folder, you should be OK, even though that looks like a long path....)


Post again with further questions....
S2_Mac is offline  
Old 07-10-2011, 02:23 PM
#3
 
Veteran Lounger
 
S2_Mac's Avatar
 
Join Date: Oct 2006
Location: About 3 feet in front of the monitor
Posts: 4,878

Totally OT remark -- as a big fan of Greg Bear's SF novels, I got a kick out of your screen name. Whether you're Olmy-the-Naderite or Olmy-the-Geshel, go enjoy an extended Talsit session...it'll ease the frustration of Consolidation woes ;-)
S2_Mac is offline  
Old 07-10-2011, 09:07 PM
#4
 
Freshman Lounger
 
Join Date: Jul 2011
Posts: 12

Wow, thank you for that incredibly helpful and detailed reply! It will take me some time to digest fully and then try out; I'll report back once I have. I really appreciate the time it must have taken you to do.

I have done a Q&D to get filename lengths (at a cmd prompt "dir /bs /a-d > \file.txt" and then loaded file.txt into excel and created a column with "len(a1)" etc to show length, then sorted.) The trouble is that I'm not 100% that there aren't files in itunes that are stored elsewhere from where I am running it that I can't remember. If I was kung-fu enough with perl or something (which I used to be, many years since I coded in anger tho) then I could write a script that parsed the .xml file looking for long names.

Eon if one of my favourite SF novels. I love the hard science behind it and some of the concepts, such as the genetic and biological engineering (I'll be first in line to get some extra storage hooked up in my skull!!). I have used the name on one or two other forums but you are the first to pick up on it!
Olmy is offline  
Old 07-11-2011, 12:06 AM
#5
 
Veteran Lounger
 
S2_Mac's Avatar
 
Join Date: Oct 2006
Location: About 3 feet in front of the monitor
Posts: 4,878

I really appreciate the time it must have taken you to do.

Eh; I've been meaning to research this, seemed like a good time ;-)

If I was kung-fu enough with perl or something (which I used to be, many years since I coded in anger tho) then I could write a script that parsed the .xml file looking for long names.

Same here; Perl skills deteriorate every day. FWIW, the iTunes XML file is fairly easy to parse. For example, if you can read the XML file into the var $s, this little block of code will produce an array of lines, each line being a path for one of your files. (The second line may not be needed for Windows, but hey -- I'm lazy ;-)

Code:
# slurp up the track-listing part of the xml file
while ($s=~m:<key>\d*</key>.*?<dict>(.*?)</dict>:sg ) {
	# de-entitize ampersand and semicolon
  $str=$1; $str =~s/&#38;/&/sg; $str=~s/&#3B;/;/sg;
	# get a path string
  $str =~m:<key>Location</key><string>(.*?)</string>:;
	# remove the "file://" bits from start of path string
  $str = $1;  $str=~s|^file://||sg;
	# de-encode path entities
  $str =~s/%([a-fA-F0-9][a-fA-F0-9])/chr(hex($1))/sge;
	# push it onto an array of lines
  push (@out,$str.\"\\r\");
}
Eon i[s] one of my favourite SF novels.

Yup. And Eternity, and the two "Forge of God" books also. I'm a sucker for that end-of-the-world stuff...add Footfall and Lucifer's Hammer to the list. But don't get me started on how evil the Brian Herbert books are...grrr. (Mortgage the house, sell the kids...but find a copy of Frank's Destination: Void; it's right up there with The Dosadi Experiment.)
S2_Mac is offline  
Old 07-12-2011, 12:35 AM
#6
 
Veteran Lounger
 
S2_Mac's Avatar
 
Join Date: Oct 2006
Location: About 3 feet in front of the monitor
Posts: 4,878

Ach! That last line of code is befuddled. (I modified it from an Applescript I use to call a shell script -- lots of escaping needed to make applescript happy; I missed cleaning up that final return char.)

The last line should read: push (@out,$str."\r");

And I always get confused by Windows....maybe it works better for you as a newline; "\n" instead of "\r"

Sorry 'bout that!
S2_Mac is offline  
Old 07-12-2011, 05:39 AM
#7
 
Freshman Lounger
 
Join Date: Jul 2011
Posts: 12

I got it done! Thanks!! I used your approach in doing a bunch of files at a time and found the culprit - a classical CD with long song titles that included artists as well as song title. Thanks again for your help!
Olmy is offline  
Old 07-12-2011, 10:58 AM
#8
 
Veteran Lounger
 
S2_Mac's Avatar
 
Join Date: Oct 2006
Location: About 3 feet in front of the monitor
Posts: 4,878

Woot! Glad you were able to work your way out of the geometry stacks ;-)
S2_Mac is offline  

Topic: Trying to consolidate library - filename too long

Closed Thread Thread Tools Topic Search

Become a member of the iLounge Forums. Register Now!
To start viewing messages, select the forum that you want to visit from the selection below.
If this is your first visit, be sure to check out the Forum FAQ and Forum Policy.
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
filenames to long to consolidate library! neelshiv iTunes + Related Mac/PC Applications 4 09-25-2007 07:43 PM
Consolidate Library id_85 iTunes + Related Mac/PC Applications 1 10-07-2005 12:48 PM
Consolidate library. Ben T iPod classic & Legacy iPods 0 05-21-2005 07:08 PM
Consolidate My Library? PaulS iTunes + Related Mac/PC Applications 1 10-25-2003 06:18 PM
long filename import bug Phil iTunes + Related Mac/PC Applications 0 10-17-2003 01:08 AM




View iLounge History. Read our old Forums Archive (2001-2003)
All times are GMT -4. The time now is 02:30 PM.


Shop for Accessories: Cases, speakers, chargers, etc.