Use C# to organise photos into date folders

23 Apr

I like to keep photos of my children in folders which are named based on the date the photos inside were taken. For example, all photos taken on Christmas Day last year are in a folder called 2010-12-25.

I finally got round to writing a quick C# console application to organise photos into folders automatically. The date the picture was taken is easy to get using the BitmapMetadata class.

Here’s the code:

using System;
using System.IO;
using System.Windows.Media.Imaging;

namespace OrganisePhotosIntoDateFolders
{
class Program
{
static void Main(string[] args)
{
string folderPath = "C:\\PhotosToOrganise";
if (args.Length > 0) folderPath = args[0];
foreach (string photoPath in Directory.EnumerateFiles(folderPath, "*.jpg"))
{
string subFolderName = "Unknown";
string photoFileName = new FileInfo(photoPath).Name;
DateTime dateTaken = DateTime.MinValue;
using (FileStream fs = new FileStream(photoPath, FileMode.Open, FileAccess.Read, FileShare.Read))
{
BitmapMetadata md = (BitmapMetadata)BitmapFrame.Create(fs).Metadata;
DateTime.TryParse(md.DateTaken, out dateTaken);
}
if (dateTaken > DateTime.MinValue) subFolderName = dateTaken.ToString("yyyy-MM-dd");
string subFolderPath = String.Format("{0}\\{1}", folderPath, subFolderName);
if (!Directory.Exists(subFolderPath)) Directory.CreateDirectory(subFolderPath);
File.Move(photoPath, String.Format("{0}\\{1}", subFolderPath, photoFileName));
}
}
}
}

Use Last.fm to find the song currently playing on BBC 6 Music in Spotify

15 Mar

We have BBC 6 Music on in the office and every so often a song comes on which I wouldn’t mind adding to my playlist in Spotify.

6 Music scrobbles everything they play to their last.fm page at http://www.last.fm/user/bbc6music. (Thanks to Steve for showing me this)

6music

The currently playing song is highlighted yellow. Click on its title to go through into the song details.

song

If the song is available in Spotify, there is a link which will open the track directly in Spotify, and that’s it.

spotify

A question of statistics

18 Dec

According to the Guardian today, 37% of Africans have a mobile phone, but only 25% have electricity. So how do they charge their mobiles?

Rafa Benitez on squad sizes

18 May

‘They have quality, especially the quality on the bench… Against us they had Ryan Giggs, Paul Scholes and Dimitar Berbatov on the bench. When they can change players of this value, these players can make the difference… So they have these kind of players, we have less of these… When you pay £20-£30million for each of these players, it is easier.’ – Rafa Benitez
Daily Mail, 18th May 2009, http://tinyurl.com/obg2ro

Uefa have branded as “ridiculous” the number of players on the payroll of the Premier League’s Big Four clubs. Liverpool, who under Rafa Benítez have stockpiled a 62-man squad, the biggest in the league and enough for more than five full teams, have come in for particular criticism.

Uefa limit clubs to 25 players each for the Champions league and their general secretary, David Taylor, speaking exclusively to Observer Sport, said: “Ridiculous. 62? You could have two full-size practice games. You can only field 11 at one time. It’s an open question as to how many you actually need. Is it 20, 25?”
Observer, 29th March 2009, http://tinyurl.com/d7epns

Afternoon TV

17 Mar

Watching Deal or No Deal at the mo. Have you got a system? Yes, I’m a big Liverpool fan Noel – so I’ll be opening the boxes in the order of the Istanbul penalty takers. First up, number 9, Djibril Cisse. £100k. Oh dear. Second number 16, Did Hamann. £50k. Ah, I didn’t know this show could be so entertaining.

Pancakes

24 Feb

Jen’s just phoned me to get me to pick up some milk and chocolate for pancakes on the way home. Aren’t you meant to use up food you already have before giving it up for lent? Jesus would turn in his grave – if he hadn’t resurrected himself of course.

It’s about emotion, respect, loyalty – and real love

19 Jan

Arsenal accounts reveal it took £10m (£5m wages, plus a private £5m one-off fee) to keep Thierry Henry for one more season. “I stayed for love,” said Thierry in 2006, before the accounts were made public. “I simply could not face leaving the fans. I’ve never played in Spain and now I never will. This is where my heart is. And my decision to stay or leave was never going to be based on economic considerations. People want to give you a label as a footballer where it’s all about money, money, money – they should stop talking about that. It’s not. It’s about emotion, respect, loyalty – and real love.”

via Football: Said and Done | Football | The Observer.

So… which details CAN I change?

7 Jan

Dear Glen Wells,

Your Dell Order is scheduled to arrive between 08:00 and 18:00 on the 12/01/2009. Please arrange for someone to be there
throughout this time – as we cannot be more specific about the time of delivery.

As your order is already on its way we regret it’s too late to change the following details:

1. delivery date
2. delivery address
3. order details

Sack the headline writer

5 Jan

The first sentence of the article: Everton’s progress to the fourth round of the FA Cup – after round-three KO’s in the past two seasons – was accomplished with relative ease. The headline: Everton squeeze past Macclesfield thanks to James Osman strike.

The man at the match says it was easy; the headline writer decides it was a squeeze. And who is James Osman?

Micro, more or less.

11 Dec

“Microsite” is a word that kinda bugs me. The “micro” means that its content is about a subset of the parent company’s overall product range. There’s the Ford site, with a bit of info about all the cars, and the Fiesta microsite, with stuff just about one car. The Fiesta has its own brand, image and target audience that differs from the Mondeo or the Focus, so they give it its own microsite. But it still has a homepage, content pages, and all the other stuff, and it’s much more sparkly and exciting in its own right than the boring dull old parent site. It’s “micro” in name only.

More recently, it’s become one of those must-have things for keen web-trend followers. We’re doing this event or that campaign so it needs a microsite. Unfortunately, there is a common misconception amongst some that have approached us on the subject, that because what they are going to write on the site is going to be about fewer things, we should charge fewer pounds to build the site for them. It’s a bit like saying the Racing Post should be cheaper than the Daily Mirror because it’s only about horses.

The fact is, just like printing a paper is printing a paper regardless of the words, it still needs the same effort in graphics work, CSS, flash, design and implementation. In fact, sometimes it needs more effort because it’s allowed to stray from brand guidelines or be more creative or adventurous. It may only have 10 pages on it when it goes live but with the CMS the customer adds those themselves anyway, so that makes no difference. It’s a bit of a customer-service conundrum: some marketing geezer decided to make up a word, people expect the price to be lower, and we get grumpy customers unhappy with the numbers on their quotes.

Follow

Get every new post delivered to your Inbox.