Getting at Date & Time with Windows Batch (bat) Files

I had the requirement today to append the current date and time onto the end of file name using a windows batch (bat) file. Thought I’d share how I achieved it…

for /f "tokens=1 delims=/ " %%a in ('date /T') do set DD=%%a
for /f "tokens=2 delims=/ " %%b in ('date /T') do set MM=%%b
for /f "tokens=3 delims=/ " %%c in ('date /T') do set YYYY=%%c
for /f "tokens=1 delims=: " %%h in ('time /T') do set HH=%%h
for /f "tokens=2 delims=: " %%m in ('time /T') do set MINS=%%m
set DATE_NOW=%DD%-%MM%-%YYYY%_%HH%.%MINS%

cd C:\yourfolder
rename "your.file" "your_%DATE_NOW%.file"

This was working in Windows XP, should hopefully work with other Windows flavours but not 100% sure.

Getting Syntax Highlighting Working with Wordpress

Really this post is entirely for my own benefit and to merely test the Syntax Highlighter ComPress wordpress plugin that I’ve just installed.

This plugin “is based on the latest Alex Gorbatchev’s SyntaxHighlighter Script” and enables “Code and source text of different mark-up or programming languages to be highlighted.”.

Well here goes, here’s some C# code…

    /// <summary>
    /// A customer.
    /// </summary>
    public interface ICustomer
    {
        /// <summary>
        /// Gets or sets the customers first name.
        /// </summary>
        /// <value>The card request.</value>
        string FirstName { get; set; }
    }

And some SQL code:

SELECT * FROM vw_tblCustomer AS C WITH (NOLOCK)
INNER JOIN vw_tblTransaction AS T WITH (NOLOCK) ON C.id = T.id
WHERE Customer.FirstName IS 'oliver'

So it does seem to work, good stuff. Good points to note, I copied the code straight from Visual Studio, the < and > characters, that appear all over the place in comments, were automatically converted into &lt and &gt. Tabs from the copied code were also conviently converted into appropriate spaces.

Bad points, it isn’t immediately obvious how to turn off the line numbering. Actually, all you need to do is add “gutter: false;” to the pre tag class as follows:

<pre class="brush:csharp; gutter: false;">blah</pre>

Will probably persevere with this, unless I find something better.

Motorolla Droid X and Issues with Search Button Long Press

UPDATE: You may now be able to get my “In-App” applications working on your Droid X handset. Please see How To Add In-App Toggle Apps to Your Notification Bar.

It has been brought to my attention by a number of Droid X users that my “In-App” Android applications aren’t working for them when performing a search key long press. Instead of launching my app or presenting the user with a choice of apps to launch, the “Voice Search” application is ALWAYS launched.

I have done some investigtion into this problem and it would appear the issue lies with the Droid X handset and not with my applications. Unfortunately for now this means that all of my “In-App” applications are incompatible with the Droid X handset, sorry for the inconvenience.

On a typical Android handset when the user long presses the search key the “android.intent.action.VOICE_COMMAND” intent is launched. This doesn’t appear to happen on the Droid X. Motorolla must have hard wired the long press to the “Voice Search” application. All other Android applications in the market that subscribe to this intent will have this issue, another example is “Button Shortcut” (take a look at some of the comments).

My First Blog Post – Welcome to My Site

This is my very first blog post on my new personal website so welcome to anyone who is reading.

I mainly intend for this site to provide information regarding some of the small software projects that have contributed to both in the past, in the present and in the future.

Hopefully this will be of use to someone :-)