Renaming Files In A Directory

So I had a problem on Windows in that I have lots of directories that are named correctly but I wish the files under them to be uniformly named.

The solution was to use PowerShell, which is an extremely effective scripting tool for Windows, especially if you come from a UNIX shell background.

There is actually quite a lot of documentation available for it and rather than go into detail I will simply show you the script:

#
# RenameDirectoryFiles.ps1
#
 
param( [string[]]$paths )
Set-PSDebug -Strict
 
foreach ( $path in $paths ) {
    if ( !(Test-Path $path -PathType Container) ) {
        Write-Error "'$path' doesn't exist or isn't a directory"
        exit 1
    }
 
    $i = 0
    Get-ChildItem $path | sort FullName | foreach {
        $tmp = "{0:000}" -f $i
        $ext = $_.Extension
        $newname = "$path - $tmp$ext"
        Rename-Item $_.fullname $newname
        $newname
        $i = $i + 1
    }
}

So the usage is extremely simple:

RenameDirectoryFiles.ps1 'My Directory'

After which all the files under ‘My Directory’ will be renamed to ‘My Directory – 000.fileextension’.

GPG Errors

Sometimes when you are installing RPM’s or Deb’s you will find yourself faced with GPG errors. Instead of ignoring them why not fix them!

Simply download the key by using the GPG tool:

gpg --keyserver pgpkeys.mit.edu --recv-key E6F33B6628973CC0

Then import that key into either APT:

gpg -a --export 010908312D230C5F | sudo apt-key add -

Or with RPM:

gpg --export -a 010908312D230C5F >key.txt
rpm --import key.txt

Simple!

Fun with Bmotion

I help out now and then with little bits of code for BMotion, the main coder is JamesOff. It is a wonderful set of scripts for AI on eggdrops. Sometimes bmotion can just spark. Check this conversation I had, both NoTopic and MonicaOff are running bmotion.

(@  NoTopic) Uh oh, it's mark.
(+      znx) listen nt .. im tired of your shit
(         *) znx kicks the crap out of nt
(         *) NoTopic passes it on to james
(+      znx) um
(+      znx) :[
(@MonicaOff) cheer up mak
(@MonicaOff) *hugs*
(+      znx) aww
(+      znx) i love you mon
(         *) znx hugs
(@MonicaOff) Hehe, want to go out on a date someplace? :)
(+      znx) sure!
(+      znx) where would you like to go mon?
(@MonicaOff) Amsterdam.
(+      znx) ooo
(         *) znx books the flights
(+ JamesOff) sounds nice :P
(@  NoTopic) oh categorically abyss what do you think, talking ass?
(+      znx) your just annoyed im not taking you nt
(         *) znx shows nt the flight tickets
(@  NoTopic) ooooh, impressive!
(+      znx) :P !!
(         *) NoTopic steals the flight tickets and runs off
(@  NoTopic) ALL MINE NOW^@~#%~£~$$~*£$$$
(+      znx) W T F
(         *) NoTopic sells the flight tickets on ebay
(+      znx) NOOOOOOOOOOooooooooooooooooooo
(         *) znx sulks at nt
(@  NoTopic) what

Of course sometimes bmotion is just plain evil!