Batch File to Delete Duplicate MP3s

Sharing this since it was pretty useful to me…

I noticed recently that I had a huge amount of duplicate files in my MP3 library. I think what had happened was that, on an iTunes upgrade, I’d rebuilt my iTunes index with iTunes set to ‘Copy files to library’. The result was thousands of files with names like “01 I Can’t Explain 1.mp3”, where iTunes had copied “01 I Can’t Explain.mp3” into the same directory, but had to rename the file.

So… What to do… Well, after seeing that the duplicate files were bit-for-bit identical to the original, but for the ” 1″ at the end of the filename, I realized I could write a simple batch file (my home PC runs Windows XP), that would find the duplicates, compare them with the originals to check that they were actually identical, then delete them:


@echo off
for /r "f:\my music\" %%I in (*.mp3) do (
if exist "%%~dpnI 1.mp3" (
echo Testing "%%~dpnI.mp3" against "%%~dpnI 1.mp3"
fc "%%~dpnI.mp3" "%%~dpnI 1.mp3" > nul
if not errorlevel 1 (
echo Match! Deleting "%%~dpnI 1.mp3"
del "%%~dpnI 1.mp3"
) else (
echo Found a non-match! "%%~dpnI.mp3" "%%~dpnI 1.mp3"
)
)
)

To be honest, it took me about an hour to figure out the right syntax for everything. I did try to neaten things up by assigning the "%%~dpnI 1.mp3" thing to a variable dupe, but gave up when I discovered that, in batch file land, variables are assigned when the line is read, not when it is executed (see this useful article for more explanation). To smarten up my batch file, not only did I have to use a strange !dupe! syntax (‘delayed variable expansion’), but I had to run it with cmd /v:on /c deldupes. In the end, I decided not to bother.

I hate batch files.

OpenSSO Integration with CAS

Hot on the heels of last week’s Jira plugin, Qingfeng Zhang (all I have is the name) has posted an an entry to the JA-SIG CAS wiki explaining how to integrate Sun Access Manager (aka OpenSSO) with JA-SIG CAS via an OpenSSO authentication module. This integration lets users login to CAS and access resources protected by OpenSSO. Nice work!

Again, I haven’t tried this out yet, but, if you have, let me know in the comments how you got on…

From the Trenches – Security for Web Services

Over at Sun Developer Network today, Sidharth Mishra talks to Marina Sum about Security for Web Services. It’s an interesting, high-level discussion, covering both the motivations for securing Web services and some of the standards and technology in the area. In particular, there’s a useful explanation of the role of the Security Token Service (STS) in brokering trust between Web service consumers and providers.

Get yourself a nice cup of tea (or, if you must, coffee ) and give it a read.

IdentiCat – captured on film

They Said It Couldn’t Be Done

Behold – a picture of the IdentiCat – clear evidence of its existence! Close examination of this video, revealed today by IdentiCat witness Daniel Raskin, shows the creature frolicking on Sun Island in Second Life, rehearsing his forthcoming presentation on OpenSSO Enterprise 8. Click here to reserve your place in the audience, in Second Life, on September 30. Now, if you’ll excuse me, I have a gross of gentleman’s jackets to load onto my tractor…

OpenSSO Authentication Modules – Hitachi Finger Vein Biometric, Verisign Identity Protection, RSA Access Manager

I’ve blogged before on OpenSSO Extensions – useful modules that do not fit into the OpenSSO ‘core’. Among the various categories of extension are ‘authentication modules’ – one of the most common customizations for OpenSSO and Access Manager. An authentication module supports a particular mechanism for collecting and verifying a user’s credentials – common mechanisms that are supported out-of-the-box include username/password against LDAP, client certificates (encompassing browser certs and smartcards) and Windows Desktop SSO (aka SPNEGO, aka Kerberos).

Of course, technology refuses to stand still, and new authentication mechanisms are constantly being developed and deployed – new biometrics, hardware tokens, even whole new authentication protocols. Over the past few months, we’ve seen a clutch of new authentication modules in OpenSSO, so it’s time to take a look at what’s new…

So, three very different authentication modules. Maybe you have an idea for a fourth?

ID-WSF 2.0 Javapolis Video Online at Parleys.com

Another entry from the ‘While-I-was-on-vacation’ department… Video from my JavaPolis ID-WSF 2.0 session was posted at Parleys.com. This is the third and final session I did at JavaPolis last year, the previous two covering OpenSSO and SAML 2.0.

There’s also a short report from the JavaPolis 2007 Speaker and JUG Dinner – you can catch a couple of glimpses of me enjoying the JavaPolis hospitality, though Harold and Alexis get speaking parts…

Making a Difference in a Sustainable Way

Kiva - loans that change lives

Prompted by James’ post, I just joined Kiva – a microfinance clearing house connecting individual lenders in developed countries (or indeed anywhere) with entrepreneurs from impoverished communities around the world. These are people who want to change their lives, but have little or no access to capital from traditional sources such as banks and credit cards. It’s a great concept – as it’s repaid, you can relend the money to other borrowers again and again and again.