Wednesday, June 17, 2015

PowerShell Script to Number mp3 Files

I downloaded a free audiobook that came in 43 separate mp3 files. The problem was that the first file "preface" was not included in the track numbering which left the files out of order.

Below is a quick powershell script to update their track numbers. This script relies on taglib-sharp:

$taglib = (Resolve-Path .\taglib-sharp.dll).Path
[system.reflection.assembly]::loadfile($tablib)
Get-ChildItem . | % { 
    @{id= ($_.name -split "-")[2]; name=$_.fullname } } | % {
  $media = [taglib.file]::create($_.name)
  $media.tag.Track = $_.id; $media.tag.TrackCount = 43;
  $media.save()
} 
 
As a bonus if you need to rename an entire directory of files, say to remove a prefix from a file name:

Get-ChildItem -filter 2011*.* | % {
    Rename-Item $_.Name $($_.Name -replace '2011','') }

Thursday, August 30, 2012

Valid Parameters for MSDepoly via MSBuild

We are in the process of automating our build processes with TeamCity. I had it all up and working great except I could not find the command line switch to prevent web deploy from removing existing files from the deploy target.

Until I found the following post on stackoverflow.com:

Here's a list I've compiled for my own reference, along with some of the legal values that can be used. Note that these are passed into MSBuild using the /p:<PropertyName>=<Value> syntax.

    DeployOnBuild
        True
        False
    DeployTarget
        MsDeployPublish
        Package
    Configuration
        Name of a valid solution configuration
    CreatePackageOnPublish
        True
        False
    DeployIisAppPath
        <Web Site Name>/<Folder>
    MsDeployServiceUrl
        Location of MSDeploy installation you want to use
    MsDeployPublishMethod
        WMSVC (Web Management Service)
        MsDepSvc
        RemoteAgent
    AllowUntrustedCertificate (used with self-signed SSL certificates)
        True
        False
    UserName
    Password
    SkipExtraFilesOnServer (leave existing non-conflicting files alone)
        True
        False

The property I was missing was "SkipExtraFilesOnServer". I hope this helps somebody else. I really wish Microsoft would make the documentation for msbuild more complete.

Also of interest my be this article: http://blog.allanglen.com/2010/12/using-tfs-2010-team-build-web-deployment-with-iis-6