Script to cleanup Windows hidden attributes and AlbumArtSmall.jpg

I wanted to remove the hidden files attributes and delete some types of files so I created the following bat-file.

attrib -R -A -S -H D:Music* /S /D
del /S /P D:Music*AlbumArtSmall.jpg D:Music*desktop.ini

(Don’t ask me why /S /D should be last on the line when using attrib and first when using del, but the manual said so.)

The first line removes all read only, archive, system and hidden -attributes on all files, folders and subfolders in folder D:Music.

The second line removes all files named AlbumArtSmall.jpg and desktop.ini from the folder D:Music and all it’s subfolders. The /P argument asks for confirmation so if you are sure you can remove it.

Easy way to convert videos using FFmpeg!

Update: I used FFmpeg for some conversions but I just found out Avidemux and it seems promising! Trying it right away!

Every once in a while I get my hands on a video file that I can’t play. Today when I wanted to watch a bouldering movie it failed. Not sure why. Maybe becuase my WLAN wasn’t fast enough to stream the huge HD file?

I looked around and found no nice tools to convert the movies. Either it was some shareware, adware or I just couldn’t find the download link on the ugly web site… I reverted and decided to try to use the command line tool FFmpeg to encode my videos to mpeg and be able to play them. It worked so good I’m amazed!

In Ubuntu FFmpeg is included in the distribution and is easy to install via Synaptic or Apt (sudo apt-get install ffmpeg). In Windows you can use these builds.

To make the conversion I used the following: ffmpeg -i OriginalVideo.mp4 -ab 128k -b 2000k EncodedVideo.mpg

Tip: If you are testing different settings for FFmpeg add -t 60 to encode only the first minute of the video.

FFmpeg is capable of creating videos with different codecs as well, but I didn’t need that currently so that will be a later exercise!

Portable backup solution for Windows

I have been thinking about creating an easy solution to backup some files from different computers to thumb drives. I wanted a solution that was portable (so I could run it from the thumb drive) and easy to configure (maximum update one path to copy from and one to copy to).

I decided to give Robocopy (that I use for complete backups) a try. The portable requirement was solved by copying the file Robocopy.exe from the folder C:WindowsSystem32 (in Windows Vista) to my thumb drive. And the easy to configure requirement was solved by creating a Backup.bat file on the thumb drive with the following content:

SET source="D:Code"
SET destination="./CodeBackup"
SET logfile="./Backuplog.log"

SET copyMode=/MIR /XF desktop.ini
SET options=/R:0 /W:0 /LOG+:%logfile% /NFL /NDL

Robocopy.exe %source% %destination% %copyMode% %options%

It copies the folder Code from my D: drive to the folder CodeBackup in the root folder on the thumb drive.

I popped out the thumb drive and stuck it in a Windows XP computer that didn’t have Robocopy installed. I ran the bat file and it didn’t work. It seems like you need to have different versions of Robocopy for it to run in Vista and XP so I downloaded the Windows Server 2003 Resource Kit which includes a Robocopy version that workes in XP. To be able to run robocopy on both Vista and XP I renamed the files to RobocopyXP32.exe and RobocopyVista32.exe. Then I updated the Backup.bat file to point to the XP version when I’m doing the backups from XP and the Vista version when doing backups from Vista. It seems to work fine and is an easy enough solution!

AutoHotkey: Swedish Dvorak (Svorak) in Windows

Update: I’ve added the layouts I use to MyDvorakLayouts at Github

I have been using Svorak (a Swedish variant of the Dvorak keyboard layout) for some years, so I’ve had the chance to use it under some different operative systems. The standard Dvorak layout is available in all (?) operative systems but the Swedish variant is available out of the box in Linux only. Luckily there are ways to install a layout, that you then can select from your keyboard settings, it in both Windows and Mac OS X. It works fine for the most part.

One issue I have been dabbling with a lot is that when switching between layouts, both OS X and Windows, it changes per application. This means that if you have Firefox and Notepad opened you’ll have to switch layout twice to get it in both applications. It’s really annoying if you switch a lot (for example if you do pair programming and switch every 10 minutes). Other annoiances are that multiple layouts sometimes seems to cause problems with inconsistent shortcuts between the layouts (i.e. ctrl-c means ctrl-c in one layout but not in the other).

Svorak with AutoHotkey

Instead of installing a keyboard layout I’m now running AutoHotkey to remap my keys. It’s a tool that allows you to create macros, so I have one (big) macro that remaps my layout from Swedish to Svorak. It works perfectly! It also makes it easy to customizatie my layout (e.g. swap CapsLock with the Left Shift key). AutoHotkey also allows to generate an executable file that’s easy to put on a USB stick and bring to other computers. Just start it and it remaps the keys. Close (or pause) it and you’ll get the Swedish layout back.

The Svorak A1 layout extended for the Kinesis Contoured
The Svorak A1 layout extended for the Kinesis Contoured

Since I’m using the Kinesis Contoured keyborad I wanted a layout optimized for that. My modifications to the Svorak A1 layout are:

  • Swap CapsLock and Left Shift. It made Shift much easier to reach.
  • Duplicate all AltGr key compinations from the right hand to the left. I did this to be able to write for example curly brackets with two hands instead of stretching one. (There is one layout called Svorak A5 that also have the AltGr combinations on the left side similar to mine so check that out as well)
  • I’ll probably remapp the Insert key to some better location than the standard (for the Contoured keyboard); Keypad + < combination.

I created different tray icons for Swedish and Svorak but I couldn’t get AutoHotkey to change between them. Hopefully I’ll be able to fix that later.

Download my Svorak A1 (extended for the Kinesis Contoured) AutoHotkey script file (you’ll need to install AutoHotkey as well). Download icon and layout files dvorak-icons

Svorak with PortableKeyboardLayout

Another flexible way of remapping the keyboard layout is to use the tool PortableKeyboardLayout. It currently supports several different layouts but not Svorak so you’ll need to install both the program and then add the layout by copying it to the layouts folder. You’ll also need to change the layouts definition in pkl.ini to: layout = dvorak-svorak-a1:Svorak A1 (Extended). Several different configuration possibilities are available, unfortunately I couldn’t find any documentation (the project is really new so that’s probably change soon!).

I ran this for a while and it worked fine! I had some issues with some GTK applications (i.e. Inkscape) but try it out. It’s really nice!

Download my Svorak A1 (Extended for Kinesis Contoured) PortableKeyboardLayout (you’ll need to install PortableKeyboardLayout). This file also contains the layout (SvorakA1Extended.klc) for the Microsoft Keyboard Layout Creator. This file was used to generate the PortableKeyboardLayout file but it can also be used as a native keyboard driver. See Microsoft KeyboardLayout Creator help for more information about that.

PortableKeyboardLayout has the possibility to display an image of the layout you are using. Unfortunately couldn’t I manage to generate the image in the correct format so there aren’t any such image for the Svorak A1 layout.

Vista and Incremental backups

I usually use Rsync for my incremental backups but since I moved to Vista it’s a bit of pain to get it working. I tried to install it using both Cygwin and DeltaCopy but couldn’t get it to copy international chars (i.e. åäö) via either Samba or SSH. So I looked into a tool called robocopy which is included in Vista (you can get it for XP as well). It worked fine and was easy to use.

To mirror a folder from one folder to another I put the following to a bat file (all on one row):

robocopy "D:Pictures"
"MyOtherComputerBackupPictures" /MIR

I did some different bat files for all folders I wanted to backup. At last I created one bat file that calls all the other. It looks like:

call BackupPictures.bat
call BackupCode.bat

There are loads of settings to customize your backups. For example to avoid copying desktop.ini files add /XF desktop.ini just after /MIR in the above example. Look into the robocopy help for more configuration options.