2012-May-20, Sunday

recordsplit.ps1

2012-May-20, Sunday 11:23 am
mellowtigger: (penguin coder)
Someone on Google Plus asked for a quick program. I couldn't format the text properly on G+, so I'm posting it here instead.

# Save this text using Notepad to a file named recordsplit.ps1
# Right-click the new recordsplit.ps1 file, then select "Run with PowerShell"
# If it doesn't run, you need to enable powershell scripts...
#      http://technet.microsoft.com/en-us/library/ee176949.aspx#EEAA

# This script separates a text file into other text files, based on the delimiter text.
# Change the first 3 variables as needed.
# If more than 999 records will be used, be sure to change the "D3" in the $newfile to an appropriate digit length ("D4")

$file='P:\ps\CraigFroehle.txt'
$delimiter='{{NEW_RECORD}}*'
$keepdelimiter=$true

$counter = 0
$fileitem = gci $file
foreach ($line in (get-content $file)) {
    if ($line -like $delimiter) {
        $counter += 1
        $newfile = $fileitem.directoryname + '\' + $fileitem.basename + '.' + ("{0:D3}" -f $counter) + $fileitem.extension
        set-content -path $newfile -value $null
    }
    if (($line -ne $null) -and ($line -ne '')) {
        if (($keepdelimiter -eq $true) -or ($line -ne $delimiter)) {
            add-content -path $newfile -value $line
        }
    }
}

Enjoy.  :)

thwarted

2012-May-20, Sunday 08:43 pm
mellowtigger: (bicycle)
I was planning to go visit a drive-in theater to watch some movies tonight, before I give up my vehicle for the summer (to commute by bicycle instead).  It would be my first and also last trip to the drive-in for 2012.

I was halfway there when the battery light appeared on my car dashboard.  It seems a bad idea to spend several hours running on battery far away from home when the battery light is glowing.  I turned around and came back.  I stopped first at the car repair shop.  I left my car there so they can work on it.  I expect to pick it up again on Monday evening.  I walked the rest of the way home.

I guess it's nearly time to turn off my car insurance for the summer.  I've been bicycling to work several days already, so I think I'm ready to do it full-time again.

In other news, the air conditioner failed at the house this weekend.  Saturday was hot and unpleasant.  The repair technician won't be here to fix it until Wednesday.  Luckily, weather should be much cooler until then.

Profile

mellowtigger: (Default)
mellowtigger

About

September 2025

S M T W T F S
 1234 56
78910 111213
14 15 16 171819 20
21 2223242526 27
28 2930    

Most Popular Tags

Powered by Dreamwidth Studios
Page generated 2025-Oct-02, Thursday 04:08 pm