Current Articles
  Archived Articles
  TECHS Articles
  Current Projects
  About Us
You are not logged in.

Please either Login or create a New Account.
Custom RSS

Note: this links is the RSS feed for the current filters shown at the top of the page. For an RSS feed for all articles in this community, click here
Nathan McClenahan (14)
Problem:  I have a bunch of video files organized in a file structure where the .mov and .wmv files are stored in the same folders.  What needs to happen is for all the files to be dumped into 2 folders based on the file type.  So in the end I'd like to have a win folder with all the .wmv files in there and a qt folder with all the .mov files in there.Solution: 
(Please read on if you are a DOS hater, you might find something that doesn't make you want to hurl.)
A little better picture of where I'm at can be seen by the directory structure.
and so on...

Ok, so I'm not DOS awesome, but I am not afraid of the command line.
(Please read on if you are a DOS hater, you might find something that doesn't make you want to hurl.)

Using a few options on the dir command we can see all the files with a particular extension in all the subdirectories.
The command "dir *.wmv /s /b" returns all the .wmv file paths in the video directory and subdirectories.
I like this.  I figure,  "Hey, if I can't get this to work at least I have a list that I can put into a batch file and do a zillion copies real fast."
But I want to really do a loop that takes care of this.

After exploring a loop for a while. I have this...
for /f  "delims="  %%a  in ('dir *.wmv /S/b') do (
    echo %%a

This gives me a nice list of files with their complete path that I want to copy. 

So I add a command into the for loop to get this...
for /f  "delims="  %%a  in ('dir *.wmv /S/b') do (
   copy "%%a" %destination%

Where %destination% is the location I want all these files to go.

Ok, so not a DOS lover?

I got to thinking that although the above is a fun solution, you could just do a winows file search for *.wmv in the appropriate folders then copy the results of that search into the target directory. 

Wow, it is fun to kill skeeters with a cannon.  But it isn't necessary. 
Tags: DOS

I ran across a situation where I need to change the extension on 195 files.  They all were names of the format <filename>.wmv.wma.  Well, being the lazy person I am, I decided to take the time that would be required to change the names and automate it.  Cool thing was I found out a way to do this by writing a batch script with about 9 lines of code.  Before you get impressed, I need to give a disclaimer that I found the idea here and tweaked it for my needs.  Be sure to play with this using files that don't matter first. 

So here's what I did.
1. I made a test folder and just made a bunch of files by copying and pasting.
2. In that folder I made a text document, and renamed it to be a .bat extension.
3. I edited that file with the following contents.
        :: renamer.bat
        @echo off
        for %%f in (*.wma) do call :renamer "%%f"
        goto :eof
        set old=%1
        ren %1 %old:~0,-5%
        :: end
4.  I had to do a little research to bone up on string manipulation, and on dos batch functions.
5.  From a command prompt I ran the batch file so I could see errors.

There are 3 key portions of the script to note.
A.  The first line in the main function uses a for loop searching for files.  So the (*.wma) finds all files with a .wma extension.  You will probably need to tweak this to match your files you want.  Note if you just use a wildcard, you will also change the name of the batch file, so that could be a pain.
B.  Spaces in the filename can do weird things.  I have added quotes to the filename parameter to keep error messages from showing up.
C.  The rename line (ren %1, %old:~0,-5%) runs the rename command with the function parameter as the old file name and a manipulation of the filename to be what is necessary.  In this case, I want to remove the right 5 characters from the filename.  So if %1 is "myfile.wmv.wma", I want to remove the .wma" and that is how I arrive at 5 characters.  The expression %old:~0,-5% takes off the right 5 characters from the value of %old. 

Well, this might be a little cryptic, but if you take the 30 seconds times the number of files you need to rename, it might be worth trying this out.

Tags: DOS

I just came across this little jem.

This site allows you to upload an image and then presents you with a color palette to use in coordination with the image.

This is useful for web design, but also photoshop.

Tags: design

What makes many windows system admins cringe?  BATCH FILES  Well, truth is they are not for the faint of heart.  But batch files are just way too handy. 
I just was presented by a colleague a problem of renaming a file to incorporate the date in the filename.  Kindof a handy thing to do in coordination with other batch type tasks.  Well, I wish I'd figured this one out, but thanks to the internet I have a cute little command that can be added to batch files or run from the command prompt to incorporate the date into a filename. 

Here are the pieces. 

1.  GET THE DATE - If you type "echo %date%" into a command prompt you will get a lovely presentation of the date.  This is an environment variable.  All environment variables are precedded and followed by a %. Today looks like "Thu 04/02/2009"

2.  FORMAT THE DATE - This is what got me... the date has slashes in it.  Pretty much a no no for a filename, so we need to strip out the important info from the %date%.  Well, there is a convention for extracting bits of a blob of text.  In the date environemet variable we can follow the word date with a colon (:) a tilde (~) and two numbers separated by a comma to indicate the start position and number characters to extract from the larger bit of text.  For example: if we want just the month from the day ("Thu 04/02/2009") we type the following. 

the result is...

This is the result of skipping 4 characters and capturing the next 2. 
Yipee! we have the month... following the same idea we can get the day, and year also.
 (come on you know you want to open up a command line and give it a try...)
Lots more information on this page...

3.  RENAME THINGS - The rename command is much simpler to deal with than the date formatting.  All you need to do is type RENAME or REN followed by two parameters.  First is the filename as it is currently, and then the filename you want it to be.  Like this...

REN nate.txt sexy.txt

Ya, all of you reading this are having error messges flash in your brain.  Remember to place each parameter in double quotes if there happen to be spaces in the file name or path to the file.

4.  PUT IT ALL TOGHETHER - Ok well put all those pieces together and we now have the tools to rename a file called happy.txt to 2009-04-02happy.txt by using the folloing command...

REN happy.txt %date:~10%-%date:~4,2%-%date:~7,2%happy.txt

This works by concatenating the year, month, day, and other text in the target filename.
Year = %date:~10%
Month = %date:~4,2%
Day = %date:~7,2%

Give it a go!
Tags: DOSexamples

I wanted to open this up, so please comment or email me  ( your favorite developer tool that is incorporated into a browser.  I'm just playing with "web developer" tool bar for firefox from Chris Pederick ( and it has some nice tools to help troubleshoot your web code. 

Add your favorites here.
Tags: resources

Recently I did a little study to investigate options for a solid printing foundation from a website.  I did a lot of research and had fun investigating the w3c's css standard for alternate media types.  Although I came to the conclusion that for rock solid printing, there is no alternative to PDF, I learned that there is considerable browser support for print media.  With that said. the most valuable concept I gathered from my research was that it is quite easy using css to make an entire site much more printer-friendly. 
Let me give my definition of printer-friendly.  The ultimate would be complete control of the margins on the page and placement of all objects on the page and meaningful page breaks.  Because of different browser implementations of the print media standard, this is a complete pipe dream.  With that said, I consider printer-friendly to be a way to print the main content of a web page without cluttering up the printed page with web navigation or cute stuff.   
Ok, enough yacking... 

There are several ways to accomplish a different css application to page elements based on the media type.  One can actually make 2 distinct .css files, one for web and one for print.  Then in the page head create the link to each one.  Another method is to include a block of css in the existing css file and enclose it in a @media print{} style rule.  Either way, browsers are smart enough to use the correct css for the media it is trying to present.  I found the best way to test this is by using the print preview option available in most modern browsers. 

Here is an example.  For a simple page with a menu block on the left and a content area on the right, we might have an html block that looks like this...

<div class=page>
    <div class = menu> Menuy things </div>
    <div class = content>  Content Stuff </div>

A typical css file might set the layout for the menu to be on the left and the content in the middle using a style like this...

.page {width:500px; }
.menu {width:200px; float:left; }
.content { width:300px; }

But by adding another set of styles we can hide the menu for print media like this...

@media print
.page {width:7in; }
.menu {display:none; }
.content { width:7in; }

This style will only be applied for printing.  The main differences are that the menu class has display:none; which hides that block and I use inches as units rather than pixels.  I like to specify the width to avoid things that extend off the right hand of the printed page.  Again, double check by using the print preview feature in your browser.

Try it out yourself with this code.


Tags: CSSexamples

I've had fun making dumb little programs for fun.  The inspiration for this came from the need to host a gathering where some group games were to be played.  So knowing that I could project my screen from my laptop I created this game to have a little fun.  It is a very basic version of hangman or Wheel of Fortune.  I've zipped up the source code and exe in this attached file.  Let me know if you have any suggestions.

Note:  Requires .NET Framework 2.0 or greater.

Below are the videos for the HTML portion of the techs class. 

Segment 1 - Tools
Visual Studio -
Edit Plus - 
Eclipse -

Segment 2 - HTML intro

Segment 3 - Class project

Nate's Sample Project -
Brian's Sample Project -
Adam's Sample Project -

Segment 4 - Headings

Segment 5 - Attributes

Segment 6 - Lists

Segment 7 - Breaks

Segment 8 - HTML Origins - Who came up with all this anyway?
W3C - World wide web consortium -

Segment 9 - Links

Segment 10 - Images

There are lots more things to explore in HTML, but the previous vidoes cover the most common things. 

I figured out this way to implement a log file for an application by using an xml file and adding it to the final compliation.  

In the solution add a new xml file.
In the properties of that file, there are 2 things to set, the build action and the copy to output direcotry.

Make sure the build action is Content
Make sure the Copy to Output Directory is Copy if newer

The settings for the "copy to output directory" are "Do not copy", "Copy Always" and "Copy if Newer"
The do not copy option doesn't put a file into the final build directory, and if this is selected, a relative reference to the file cannot be obtained.  The copy always option copies the file as it exists to the build directory for every build, and therefore will delete any changes you made programmatically.  This is not desirable when you are testing.  The copy if newer allows for only copying the file over if the original file has changed and therefore has a newer timestamp. 

These settings ensure that the file is copied to the bin/debug folder on a build.  Then one can reference the xml file in a relative manner so the path need not be known.

Here is an example of a routine to open a log file and append an entry. 

Public Shared Sub AddEntryToLog() 
    Dim xmlDoc As New System.Xml.XmlDocument() 
    Dim objElement As Xml.XmlElement = xmlDoc.CreateElement("entry") 
    objElement.InnerText = "Added a log entry."
    objElement.SetAttribute("date", "4/2/2008") 
End Sub

Here is the log file with the entry from above.

<?xml version="1.0" encoding="utf-8"?>
<!-- Logs of reminders sent.-->
<entry date="4/2/2008">Added a log entry.</entry>

Here is a sample project that can be used as an example for the TECHS class.

When you enter text into the textbox and once you hit enter(firefox only) or tab, then the page starts a list with the text that was entered into the textbox.  If you don't like the item in the list, click on the text and it is removed.

This is kindof a dumb thing, but it demonstrates how html, CSS, and Javascript can work together.
Below is the code...

For fun put it into a page on your computer and play with it.  Who cares if you screw it up, you can always come back here and get it again.

    <title>To Do List </title>
    <style type="text/css">     
        .inputbox { width:800px; height:100px; text-align:left; vertical-align:middle;  color:#ffffff; font-size:20pt;}
        .listbox { border:1px; border-style:dashed; background-color:#665533; }
        .list { color: #002277; background-color: #665533; font-family: Corbel, Arial Black, Arial; font-size: 30pt;}
        .listitem {  background-color:#774499; width:90%;}
        .listitem-alt {  background-color:#550077; width:90%; }
        body { background-color:#775500; }
        input { font-family: Corbel, Arial Black, Arial; font-size: 30pt; color:#669944; }
<body >

    <script language="javascript" type="text/javascript">
  var blnAlternate;
  function AddItem()
   var lstToDo = document.getElementById("lstToDo");
   var txtItem = document.getElementById("txtAddItem");
   if (txtItem.value != '')
           var lstItem = document.createElement("li");

           if (blnAlternate == true)
                   lstItem.innerHTML= "<span class='listitem-alt'  onclick=RemoveItem('" + txtItem.value + "')>" + txtItem.value + "</span>" ;
                         blnAlternate = false;
           lstItem.innerHTML= "<span class='listitem'  onclick=RemoveItem('" + txtItem.value + "')>" + txtItem.value + "</span>" ;
                         blnAlternate = true;
  function RemoveItem(strItem)
      var lstToDo = document.getElementById("lstToDo");
      for (index=0;index<= lstToDo.childNodes.length;index+=1)
      var lstItem = document.createElement("li");
      lstItem = lstToDo.childNodes[index];
      if (lstItem.innerHTML.indexOf(strItem) > 0)

    <div id="divAddBox" class="inputbox">
    Build your own todo list<br />
    Enter items in the box below and they will appear in the todo list.
        <input type="text" id="txtAddItem" onchange="AddItem()" />
    <div id="divList" class="listbox">
        <ol id="lstToDo" class="list"></ol>

Tags: CSSexamplesHTMLJavascriptTECHS

  1 2