A DECADE ago, during the 90th anniversary of the outbreak of the First World War, I found myself writing the following sentence:

"If a Bavarian machine-gunner opened fire on an infantry company whose members came from the same locality in, say, Wester Ross, then the losses would be not only horrific but they would be spread thickly across a small and perhaps fragile community."

At the time I was finishing Flowers Of The Forest, my history of the role played by Scotland in the First World War, and I was trying to make sense of the human cost of the conflict. The official figures tell one story. At the time of writing that sentence the figure recorded by the Scottish National War Memorial was 148,218 Scottish casualties compared to the total for the British Empire of 908,371, or the German losses of 2,037,000.

Yet it was already clear to me that the "war to end wars" had cast a long shadow over Scotland's development and changed the way it viewed itself as a nation, for scarcely any family had been unaffected by those losses.

How to make sense of them was another matter. We already live in an age when the deaths of British soldiers in Afghanistan can dominate the main evening television news, with associated demands for information and analysis.

Indeed, as I was writing the above words in 2004, three soldiers of the 1st Black Watch had been killed by a suicide bomb while serving in an unpopular deployment in Iraq that November, and their deaths sparked considerable outrage across Scotland. Compare this to the 20,598 killed in action at the Battle of Loos in the autumn of 1915 - one-third of the casualties being Scots - and the extent of the problem becomes clear.

An opportunity to resolve that dilemma came my way four years ago when the BBC asked me how we could make sense of Scotland's losses during the First World War.

Who were those victims and what was the effect on their communities, on parents who would not see their sons grow up, on young women made unseasonable widows, on a generation of fatherless children?

My response was that the only way to understand the figures was to humanise the death-toll: identify the attacking rifle company and pinpoint not only where they died but the community from which they had come.

From the outset my gut reaction was that the answer would be found in one of three Highland regiments which had expanded their numbers enormously during the conflict - the Seaforth Highlanders, the Gordon Highlanders or the Cameron Highlanders, all of them representative of the close-knit communities where they found their recruits. (Today they live on in the 4th Battalion The Royal Regiment of Scotland.)

Clearly the greatest number of Scottish recruits came from the densely populated central belt and saw service with regiments such as the Cameronians or the Royal Scots (which alone suffered 11,213 men killed on active service). But if a fragile community had to be found it was more likely to be in the agricultural northeast or the Highlands and Islands of the northwest.

One other factor had to be taken into account. At the outset of war in the late summer of 1914, Scots in the crucial 18 to 41 age group flocked to join the new "service" infantry battalions which were being raised by Secretary of War Lord Kitchener for wartime service, or if they were already part-time soldiers of the Territorial Force they immediately volunteered for service overseas.

As there were 10 Scottish Regular Army infantry regiments, all of which rapidly expanded their Service and Territorial battalions, there was no shortage of choice for young Scots anxious to join up.

Within a day of the declaration of war the army's recruiting office in Edinburgh's Cockburn Street was doing brisk business under the judicious eye of Captain William Robertson, a Gordon Highlander who had won the Victoria Cross in the Boer War. By the end of August, the Glasgow Herald reported 20,000 men had been processed through the city's recruiting office in the Gallowgate.

From other parts of Scotland came news of equally high figures of enlistment during August - 1500 from Coatbridge, 900 from Clydebank, 940 from Dumbarton and 750 from Alloa. Recruits in Inverness rushed to join a service battalion of the Queen's Own Cameron Highlanders that was being formed by DW Cameron of Lochiel. It would fight as the 5th Camerons and Lochiel offered his personal guarantee that "at the end of the war the battalion would be brought back to Inverness where it will be disbanded with all possible dispatch".

A number of factors prompted those volunteers from all over Scotland to take the King's Shilling.

Workers doing repetitive or menial jobs saw a chance to escape the drudgery of their existence. The Scots' inherent respect for the military life also encouraged many a young man who thought he would look a god in a kilt and a Glengarry bonnet.

In those days, too, words such as duty, honour and patriotism were not idle concepts but the cornerstone of many young lives: within a year the Rev Duncan Cameron, minister of Kilsyth, claimed that after painstaking research, he had found that 90% of the country's ministers had seen their offspring ("sons of the manse") volunteer for duty in the armed forces.

Unskilled workers or the unemployed looked forward to the prospect of work and a steady wage but as was reported on August 8, 1914, the recruits in Edinburgh's Cockburn Street came from all walks of life: "Men of all types and classes passed along, some in professions and trades - well groomed and spruce - and others with whom the world had dealt more hardly, but all curious to take their places in the ranks and shoulder a rifle."

Peer pressure was brought to bear on the undecided; there was a general feeling that the whole thing was a bit of a lark and that it would be a shame to miss the great adventure. Few seem to have given any thought to the dangers that lay ahead or even that warfare would bring casualties.

And that was certainly going to be an issue. Because young Scots had joined the army in such droves it meant that they would be channelled more quickly into the training regime which transformed them from raw civilians into frontline soldiers prepared to kill or be killed. In other words, the young men who joined up with such gay abandon in the late summer and autumn of 1914 were ready to take up the soldier's trade in time for the first great battles of attrition a year later - Neuve Chapelle, Aubers Ridge, Festubert, Givenchy and Loos. For many of those young Scots it would be their first and last experience of battle.

However, before proceeding any further with the idea for a programme, we had to find our cluster of soldiers, the as-yet unknown band of brothers who would give the film its core. Their names existed somewhere in the regimental records and in an extraordinary publication produced in the 1920s called Soldiers Died In The Great War 1914-19, with volumes devoted to individual regiments listing the names, hometowns, enlistments and battle-fronts of every soldier who had laid down his life for King and country (as the easy euphemism of the period has it).

Reading those soulless catalogues of death was a grim and unnerving business even though they are housed in the imposing martial surroundings of Fort George outside Inverness, and despite the fact that they belong to an irretrievable past.

So many names and so many young lives extinguished; easily recognised brothers wiped out and evidence (especially in the Seaforth volume) of island township communities destroyed by news of the death of their young men in distant France and Flanders, or the equally unknowable wastes of Mesopotamia and Salonika.

After one or two false starts we found what we were looking for - a group of young men who had served together in a Territorial battalion as "Saturday night soldiers". They all came from Portree and its neighbourhood on the Isle of Skye, they all served together in D Company (old G and H companies), 4th Queen's Own Cameron Highlanders, and many of them were killed in the evening of May 17 1915 during the Battle of Festubert.

This largely forgotten encounter was fought as part of a "push" by 7th Division over a landscape which the divisional historian described as "flat country, in places marshy, intersected with ditches, devoid of good artillery positions or facilities for observation, little improvement on the waterlogged meadows with which the Division was so painfully familiar". (Having walked the battlefield several times I can confirm this is not an exaggeration.)

The 100-odd boys from Portree were fairly typical of the young men who had joined the Territorial Force after its foundation in 1908. All were local, all were friends and all were looking forward to the excitement of service overseas under the command of officers and non-commissioned officers whom they admired and trusted - men such as Captain Ronald MacDonald, senior partner in a local firm of solicitors, or CSM William Ross, a shoemaker before the war and revered as the "father of the battalion".

At a special BBC screening of the film in Portree last week it became clear that quite a few members of the audience were descended directly from those young men and were rightly proud of the fact.

By the time filming began in Scotland and France in April last year we had an enthusiastic presenter in the shape of the military archaeologist and television historian Neil Oliver, and he teased out the names and identities of "our boys" (as we had come to regard them). This meant that when we set off to follow them to the Western Front, the soldiers of D Company were not just names from the war memorial in Portree's Somerled Square but vibrant young men with the rest of their lives stretching out in front of them as they embarked on their first big ­adventure. Also, and this needs to be said, they were not going as lambs to the slaughter but as well-trained, well-equipped and well-led soldiers with a considerable conceit of their military abilities.

That all ended on a muddy expanse of ground in distant Artois in northern France when they had the misfortune to run into the unimaginable killing power wielded by hidden German machine-gunners. That is the back-story to Skye's Band Of Brothers and its outcome was as tragic as it was inevitable. Suffice it to say that during this unnecessary battle two officers and 46 men of D Company were killed and the local community in Skye faced a lifetime of despair after the War Office telegrams started arriving to announce the deaths of so many young men.

As the making of the film was coming to an end there was a moment of epiphany when we discovered that the incident had been memorialised by the great Gaelic poet Sorley MacLean, a pupil in the local school in Portree in the 1920s, who imagined youngsters being called out of the classroom to be told the fate of fathers, uncles or brothers, the banging of the school doors replicating the monstrous anger of the guns on the far-off Western Front.

All told, there was no easy moral here, no justification for what happened, and certainly no happy ending, just the story of around 100 young Scots and their German opponents brought together by the accident of history and paying the price of being players in the bigger game that was the First World War. But perhaps it need not end so bleakly. From the universal to the particular, something approaching truth might just emerge from the experiences of those boys from Portree, anonymous no longer but now restored to the beating heart of the community.

Festubert by sorley MacLean

Rattle of the little guns

and clangour of the big guns

heavy doors being shut

with the blast and crash of tempest;

whizz and whine of the shells

about Festubert and the mud and bloodshed;

big heavy doors shutting

on many a brave strong young man.

Doors opening quietly

and shut as they were opened:

boy or girl, or two or three,

taken out of the schoolrooms,

having to go home

down by the Big Bridge,

to the middle of the town,

or south to Lots,

or north to Sluggans,

down to the Pier,

or down to Sligneach,

east to Stormyhill,

or over to Black Street:

to every house where sorrow was,

brothers or fathers dead:

thirteen on one day

in the little town of Portree,

thirteen men in Portree

and many another man

between Trotternish and Sleat,

between Duirnish and Strath,

between Bracadale and Raasay,

between Minginish and Rona

between Uist, Harris and Inverness.

Doors opened and closed

quietly in many a house,

and the children going home

to weeping or to silence.

Clangour of the big guns,

blast of heavy doors being shut

about other towns in France

and throughout Europe,

and doors opening quietly

to dwellings of the broken heart.

'Of the 28 who marched away from Portree, only eight survived'

Neil Oliver talks about The Machine Gun And Skye's Band Of Brothers

"OUR film illustrates the impact of one day's battle upon a small group of people, and upon the families back home.

"Of the 28 who marched away from Portree, only eight survived the war.

"Britain and the empire lost around 900,000 people during the First World War. No-one can picture that. But you can imagine what would happen to your own street if some of the schoolteachers and dads and bus drivers went off to a war and never came back.

"That would never be forgotten in your neighbourhood. Those people would be missing forever and you would feel it.

"During the Great War many young men died before the point at which they had been able to have children of their own. After 100 years, if they are remembered at all, it's only as names on a stone.

"They lost more than their lives, their potential careers and what they might have done.

"Because their seed did not go on into the population that we live with today, they lost everything in every conceivable way.

"The nature and scale of their loss is such that they simply ought to be remembered."