• Renaming date-named folders using PowerShell

    Since I’ve been using the Windows 7 [Import Pictures and Videos]/2010/02/changing-location-of-pictures-and.html) wizard to upload photos from our digital camera, we’ve used the directory naming scheme of YYYY-MM-DD. Prior to this, I’d written my own custom photo importer in C++ as I didn’t like the naming schemes that Windows XP offered. Unfortunately I’d chosen YYYYMMDD instead.

    I’m now consolidating all our digital photos onto our Windows Home Server. This makes them easier to browse on the big screen using Windows Media Center, and has the added benefit that they also get backed up to the cloud via a subscription to CrashPlan.

    I discovered the downside to having the different naming schemes when you go to view the photos in Media Center – it displays the folders out of order because they don’t all follow the same format.

    PowerShell to the rescue:

    cd \\homeserver\photos dir | Where-Object {$_.Name -match “^\d{8}$” } | Rename-Item -NewName { $_.Name -replace “^(\d{4})(\d{2})(\d{2})(.*)”, “`$1-`$2-`$3`$4” }

    This finds directories matching the old naming scheme and renames them to conform to the new one.

    My C++ importer imported all photos into a single folder, so to avoid overwriting the same folder if you imported twice on the same day, I would add a .0 (or .1 etc) to the end of the folder to ensure it was unique. There weren’t too many of these though, so I dealt with them manually.

  • Free licenses for WP7 EQATEC Profiler

    If you’re a Windows Phone 7 developer, you may have come across Eqatec’s Profiler. As far as I know, it’s currently the only performance profiler that supports WP7 applications (Red Gate have indicated that they will support WP7 in 2011 Q4).

    I’ve made use of Eqatec Profiler already, as there is a free version available, but with some restrictions (such as only profiling a single assembly).

    Now in exchange for trialling their analytics product, they’re offering upgrades to give you free licenses to the less-restricted versions.

    As well as WP7, the product also support profiling regular .NET, Silverlight, Services, ASP.NET and even .NET CF.

    I participated in the analytics evaluation and got 21 points which entitled me to a ‘Professional’ profiler license (normally $US399).

    So what did I think of the analytics product? Well it seems quite solid, and didn’t have any noticeable impact on my test apps. If you were selling software commercially then it might be of interest, but the price is prohibitive for those of us who have only released free software so far.

  • Windows 7 Boot to VHD

    For my own reference, some useful resources about boot to VHD:

    Following instructions from http://technet.microsoft.com/en-us/library/dd979534%28WS.10%29.aspx


    create vdisk file=C:\VHD\test.vhd maximum=25000 type=expandable      select vdisk file=C:\VHD\test.vhd      attach vdisk      create partition primary      assign letter=v      format quick FS=NTFS label=VHD exit


    PS C:\VHDs> .\Install-WindowsImage.ps1 -WIM D:\sources\install.wim

    Index   Image Name [1]     Windows 7 Home Basic [2]     Windows 7 Home Premium [3]     Windows 7 Professional [4]     Windows 7 Ultimate


    PS C:\VHDs> .\Install-WindowsImage.ps1 -WIM D:\sources\install.wim -Apply -Index 4 -Destination v: Applying “Windows 7 Ultimate” to v:… WARNING: This may take up to 15 minutes…

    V:\Windows\System32\bcdboot V:\Windows

    bcdedit -v

    bcdedit /set {GUID} description=”Windows 7 VHD”

    Useful utility BCDEdit - http://neosmart.net/downloads/software/EasyBCD/EasyBCD%202.0.2.exe