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


Click here to return to the 'Staying Organized' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Staying Organized
Authored by: hypert on Sep 15, '04 01:06:27AM

You don't need to select all the tracks you want to delete, add a comment, search for the comment in the library, and then press Cmd-Delete. Just select them in your playlist and press Cmd-Opt-Delete. This will remove them from your playlist AND from your Library!



[ Reply to This | # ]
Staying Organized
Authored by: hypert on Sep 15, '04 01:08:57AM
I just submitted this a little while ago as a new "hint", but now that I found this thread, I'll try to post it here. For some reason, I end up with a ton of "duplicate" tracks in my iTunes library and playlists. By this I mean that more than one track in iTunes maps to a single file on my hard drive. (I may get into this problem because I sync my files between my Mac and my PC, and an ID3 tag change made on my PC may cause iTunes on the Mac to think it's a whole new track when I re-drop the files back into iTunes.) Anyway, Doug Adams has some great Applescripts available to find and/or delete "dupes", but they don't always work for me. So, I wrote a Perl script to parse the "Song List" which can be exported from iTunes (in the File menu). There are 25 different "fields" associated with every track in the list, and the Perl script allows you to easily pick which fields you want (by editing the Perl script where documented). Here's the script:

#!/usr/bin/perl -w

use strict;
my $song;
my $lastSong = "";
my @songs;
my $DEBUG = 0;

if (scalar(@ARGV) == 0) {
    print "USAGE: $0 <filename>\n";
    print "The <filename> must be generated from iTunes' \"Export Song List\" function.\n";
    exit 1;
}

{
    # The exported file uses the Mac file delimeter.
    local $/ = "\r";
    my $file = shift;
    open(F, "$file") || die "Cannot open file '$file'.\n";
    @songs = <F>;
    close(F);
}

# Take off header row.
my $header = shift @songs;
if ($DEBUG) {
    # If you set $DEBUG, you'll see what each of the header fields are.
    # You can use this set which of the fields to use when determing dupes
    # (in the "map" statement a few lines down).
    my @header = split("\t", $header);
    for (my $i = 0; $i < $#header; $i++) {
	print "Field $i:\t$header[$i]\n";
    }
    print "\n";
}

# Consider four of the fields (Artist, Name, Album, Size) for the duplication calculation.
# If you set $DEBUG, some code above will print out what each of the header fields are,
# and then you can pick any fields to be included in there duplicate calculation here.
@songs = map { my @fields = split("\t"); "$fields[1]\t$fields[0]\t$fields[3]\t$fields[6]" } @songs;

@songs = sort(@songs);

foreach $song (@songs) {
    print "Looking at $song.\n" if ($DEBUG);
    if ($song eq $lastSong) {
	print "Duplicate: $song.\n";
    }
    else {
	$lastSong = $song;
    }
}


[ Reply to This | # ]