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


Click here to return to the 'A Perl script to find duplicate iTunes tracks' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
A Perl script to find duplicate iTunes tracks
Authored by: DougAdams on Sep 17, '04 03:18:42PM

Can anyone make this executable for "Person Who Knows Poop About Perl"? I have gotten a ton of emails on this particular article like I'm the one who wrote it. Perl newbies are clueless. How about a hand?



[ Reply to This | # ]
poopless perl executable
Authored by: SOX on Sep 17, '04 04:28:10PM
first the above single line is in fact a perl executable as it is written. but if you want to hide the complexity of this in a file then:

open a terminal window and cut and paste the following into the terminal followed by pressing control-D. The cat > dup_find will create file called dup_find with the rest of the text in it.


cat > dup_find
#!/usr/bin/perl 
# identify duplicates that have same four first fields
$/ = "\r";
while ($d = ) { 
     @F = split /\t/, $d ;
    $x = join " ::\t",@F[0..4]; 
    print $x,"\n" if $h{$x}++;
}

next make it executable:
chmod a+x dup_find

this will run from the command line as:
./dup_find name_of_exported_song_list_file

voila. But as I said the original 1 line perl is executable from the command line and would go nicely inside an applescript

I leave it to you to wrap a dropplet apple_script around the single line command.

[ Reply to This | # ]

Darn html!!!
Authored by: SOX on Sep 17, '04 04:35:31PM
arggh! its so hard to get code to show up right in these comment boxes. The last one was missing the <> symbol since it got removed by the htlp filter.

cat > dup_find
#!/usr/bin/perl 
# identify duplicates that have same four first fields
$/ = "\r";
while ($d = <>) { 
     @F = split /\t/, $d ;
    $x = join " ::\t",@F[0..4]; 
    print $x,"\n" if $h{$x}++;
}



[ Reply to This | # ]
poopless apple script dropplet perl version
Authored by: SOX on Sep 17, '04 06:08:46PM
here is an applescript droplet. This dropplet takes an exported song list file and replaces it with a new file that contains only the duplicate names. the original file is not deleted but rather renamed with a ".orig" suffix.

-- This droplet finds duplicates of songs from an exported song list file.
-- Author: Charlie Strauss 2004
on open this_item
	
	set target_name to this_item as string
	set posix_target to quoted form of the POSIX path of target_name
	
	
	
       set command to 
	  "perl -i.orig -0x00d -nwaF\"\\t\" -e '$x = join \" ::\\t\",@F[0..3]; print $x if $h{$x}++ '  "
	
        try	
		do shell script command & posix_target
		
			
	on error error_message
		beep
		display dialog "Whoa! " & error_message buttons 
			{"Rats"} default button 1
	end try
		
end open


[ Reply to This | # ]
poopless apple script dropplet perl version
Authored by: SOX on Sep 17, '04 06:37:40PM
here is an applescript droplet. This dropplet takes an exported song list file and replaces it with a new file that contains only the duplicate names. the original file is not deleted but rather renamed with a ".orig" suffix.

-- This droplet finds duplicates of songs from an exported song list file.
-- Author: Charlie Strauss 2004
on open this_item
        
        set target_name to this_item as string
        set posix_target to quoted form of the POSIX path of target_name
        
        
        
       set command to 
          "perl -i.orig -0x00d -nwaF\"\\t\" -e '$x = join \" ::\\t\",@F[0..3]; print $x,\"\\n\" if $h{$x}++ '  "
        
        try     
                do shell script command & posix_target
                
                        
        on error error_message
                beep
                display dialog "Whoa! " & error_message buttons 
                        {"Rats"} default button 1
        end try
                
end open


[ Reply to This | # ]
Perl newbies
Authored by: gourls on Sep 17, '04 06:23:58PM
Hey, I don't think that the guy who wrote the article is clueless, if he did get the script to work for him. So he might know somethin somethin about Perl. I noticed he mentioned your name in it. Sorry Doug, you'll have to deal with the emails by yourself. Do you know who hypert is?

---
if you must speak, speak of topics that may never be discussed again........... ....cheers, gourls

[ Reply to This | # ]

Perl newbies
Authored by: DougAdams on Sep 18, '04 08:33:50AM
I am well aware that the guy who wrote the hint is not clueless. I just don't think he anticipated the large number of people who would be enthralled by his hint who also don't know the first thing about Perl scripting. Can't blame him for that! (I address this in another comment in the main thread.)

[ Reply to This | # ]
Sorry
Authored by: gourls on Sep 30, '04 08:30:51PM
I'm sorry Doug. I don't know what I was thinking. I need to learn better. Sorry if I offended you in any way. :)

---
-brita

[ Reply to This | # ]