Shared posts

27 Sep 08:58

Enhedslisten forudser: Vi får forsøg med e-valg inden for nogle år

by 1385

Det var først og fremmest lovforslaget om e-valg, der var noget galt med, ikke e-valg som sådan, lyder det fra Enhedslisten.

13 Sep 23:30

You Can't Make This Stuff Up: FinnAir's Flight 666 Flies to Helsinki (IATA Airport Code "HEL") on Friday the 13th

You Can't Make This Stuff Up: FinnAir's Flight 666 Flies to Helsinki (IATA Airport Code "HEL") on Friday the 13th

That's right:

Flight 666 to HEL on Friday the 13th.

Despite being a superstitious person's worst nightmare, the flight was reported to be "almost full," said Juha-Pekka Keidasto the pilot who flew the Airbus A320 from Copenhagen to Helsinki. Keidasto also stated that he is not a superstitious man and that it was "just another flight" for him.

I'm betting he had a lucky rabbit's foot in the storage box next to him, though.

The flight arrived three minutes early in Helsinki without incident.

Would you fly on Flight 666 to HEL on Friday the 13th?

Submitted by: Unknown (via flightaware)

20 May 07:01

Use PowerShell to Copy Only Folders that Contain Files

by The Scripting Guys

Summary: Microsoft Scripting Guy, Ed Wilson, talks about using Windows PowerShell to copy only folders that contain files.

Microsoft Scripting Guy, Ed Wilson, is here. In some respects, it seems like I have been using Windows PowerShell for a long time. In other respects, it seems like the journey begun only a short while ago. I mean, after writing five books about Windows PowerShell, it would seem that I know the product pretty well. And yet, I continue to amaze myself with the power of Windows PowerShell.

What am I talking about? Well, a few months ago, I created a whole bunch of folders based on dates in preparation for the Scripting Wife’s and my trip to Europe. Unfortunately, due to certain time issues, I did not always upload pictures every day into the folders. This caused some folders to not have pictures in them. Now when you are talking about 40 or so folders, it is annoying to click and not see anything. So I decided to delete folders that were not being used. At first I was going to do it by hand, but that was painful. I thought the code to clean up the empty folders might be too difficult to write, but in the end, it was not.

Delete empty folders

I opened the Windows PowerShell ISE, and created two variables to hold the source path and to hold the destination path. These two variables are shown here (note that you will not have these directories unless you have created them):

$path = 'C:\data\mypics\2012'

$destination = 'e:\data\mypics\archive\2012’

Now I use the Get-ChildItem cmdlet to collect all of my directories. I use the Directory switch that is available in Windows PowerShell 3.0 to do this. I send the directory objects down the pipeline. This is shown here.

Get-ChildItem $path -Directory |

Now I use the Foreach-Object cmdlet to work with each directory object. I call the EnumerateFiles method from the DirectoryInfo object to see if there are any files. I send the results to Measure-Object to count the files. I am sure this code could be cleaner, but it works:

Foreach-Object  {if (($_.enumeratefiles() | measure).count -gt 0)

If there are files, I copy the folder (and files) to the destination as shown here:

Copy-Item -path $_.fullname -Destination $destination -Recurse}

That is it. It did not take me very long at all to create the script. And it saved a whole lot of clicking. Here is the competed CopyOnlyFoldersWithFiles script.


$path = 'C:\data\mypics\2012'

$destination = 'e:\data\mypics\archive\2012’

Get-ChildItem $path -Directory |

Foreach-Object  {if (($_.enumeratefiles() | measure).count -gt 0)


   Copy-Item -path $_.fullname -Destination $destination -Recurse}


Join me tomorrow when I will talk about more cool Windows PowerShell stuff.

I invite you to follow me on Twitter and Facebook. If you have any questions, send email to me at, or post your questions on the Official Scripting Guys Forum. See you tomorrow. Until then, peace.

Ed Wilson, Microsoft Scripting Guy