Bulk renaming files in Linux

For some time it’s been annoying me that the various GUI file renaming options in Linux weren’t quite good enough. They either require manual previewing/actioning each and every directory or those that do recursive processing were just very limited.

So, after finding this offering to get me started, enter the following shell script which I’ve put together to replace the three most annoying characters that Linux allows in file names (and which the various MP3 ripping programs also permit and don’t clean up):


# Replace double quotes with single quotes
find . -name '*"*' -depth -exec rename -v "s/\"/\'/g" {} +

# Strip question marks entirely
find . -name '*\?*' -depth -exec rename -v "s/\?//g" {} +

# Replace colons with periods
find . -name '*:*' -depth -exec rename -v "s/\:/\./g" {} +

Save the above to a file and set it to executable (chmod 755 filename.sh) and Bob’s your uncle. I still have quite a lot of tidying and tagging ahead of me after going on a CD-buying binge for the past 12 months, thanks to a stellar Aussie Dollar exchange rate, but at least I can now copy various MP3 rips to a FAT32 USB key and take them to work without Windows Explorer bitching at me.

Meh. The code isn’t showing entirely in the correct font/colour but I’m sure you’ll cope :-)

Desert Colour Scheme for NetBeans

Eyeball a white screen whilst programming for too long and your eyes are going to hurt, so a sympathetic colour scheme is essential. My favourite scheme, or at least the one I became used to when I used gedit a fair bit, is called Desert (no longer available, so here’s my copy), which is based on the Desert scheme for vim. Lately I’ve been using Geany to take advantage of a few more features, so here are of the relevant files from my “~/.config/geany/filedefs” directory which I modified to implement the same colours.

However, this Christmas I intend to read Programming Clojure, a book I bought just over a year ago! And since I haven’t been able to cope with emacs or vim, I was forced to once and for all put in the time to implement the Desert colour scheme in NetBeans. The process was quite laborious, so hopefully this will be useful to those who find the default offerings a little meagre.

Here’s a sample of the colour scheme, showing defpackage.clj from the clojure examples in the book. I have also configured these same colours for other file formats I use often, such as PHP, HTML, JS, CSS, SQL, and knocked up the others as best I could in the time available. NetBeans sure doesn’t make this easy, but you gets what you pays for :-)

(picture: preview showing desert colour scheme

Download: Desert Colour Scheme for NetBeans 59.3 KB (created with 6.9.1)

To install, open NetBeans, go to Tools > Options, then click on Fonts & Colors, then click the Import button at the bottom and browse to the file downloaded above. Enjoy!

Two years using Linux and I’m in computing heaven

This morning I wanted to scan an image, so I fired up Simple Scan in Ubuntu and clicked the scan button (by the way, using my cheap CanoScan LiDE 20 for which there was no 64-bit Windows 7 support for quite some time – now supported with a 10 MB driver/software download – but which Ubuntu supports out-of-the-box with no effort on my part). As soon as I see the picture on screen I decide to see if I can just stop it there and save what I want. Lo and behold, it doesn’t complain, I crop the image and click save, and it just saves without having to scan the image again like most dumb-ass commercial scanning packages. Very impressed.

I then decide that the image is a little too big, and not wanting to fire up The GIMP like I have been doing until now, I decide to search for a better way. A short Google search later and I find the nautilus-image-converter add-on to Ubuntu’s file manager. A mere 30 KB download using the Synaptic Package Manager (Add/Remove Programs on steroids for you Windows slaves) and a re-login later and I’m resizing images with ease.

If you search for “free image resizer windows 7” you get quite a lot and the only link I could safely say is free of viruses and spyware is Google Picasa, but since it appears in the Ads section, anybody with half a brain should be wary these days (except Google in this case). Search for any Windows software and you’re more likely to get spyware than not. Being a Linux user I don’t have that problem because my software only comes from a trusted source, and not the likes of FileHippo.com or soft32.com.

I started using Linux seriously exactly two years ago when I happily took the buggy Windows Vista off my media centre PC and installed Mythbuntu 8.10. At the time I had to tinker a little to get my remote control working and a few other things but since installing 10.10 last weekend, I found it was an absolute cinch! By default it installed Samba and configured the same shares I did two years ago, there was an option for my remote control, and it looks more polished than before. The only thing I did as before was enable low noise amplification on my TV card. And since the transmitted digital TV guide in Australia is pretty decent now, I don’t even need to install Shepherd, which has served me very well. The new version of MythTV even comes with a Python script that automatically downloads matching artwork for my favourite TV recordings such as The Colbert Report and The Daily Show with Jon Stewart. My brother has been complaining about his unstable Windows 7 Media Center install (six months old). I might have to burn him an ISO of Mythbuntu. So, I wouldn’t even go back to Windows Media Center now if Microsoft paid me!

In the past I have said some very unpleasant things about PHP but now it’s all I use. It’s true that its function names are all over the place and everything is in the global namespace, but it’s just so darn convenient and widespread. Much like VB was looked down upon in the Windows world as a toy language, it didn’t change the fact that it made people’s lives easy and therefore became very popular. As far as languages go I’d really like to find the time to read the dead-tree edition of Programming Clojure that I bought (under the influence of the proselytisation of a better programmer than myself), but at the end of the day it’s all about results, and with PHP I’m more productive. Now I’m mixing PHP on the server with Ext JS on the client thanks to another good book, Learning Ext JS. I can’t see me installing a Windows Server at home any time soon.

If an operating system requires me to install anti-virus software then I’m going somewhere else. Using a virus scanner gives you a false sense of security and doesn’t do much except drastically slow down your computer. One of the best articles I’ve ever read on why Windows sucks big time is The Six Dumbest Ideas in Computer Security. Windows commits most of the sins mentioned and even with things like User Account Control I still wouldn’t use Windows 7 at home. You would have to pry Linux from my cold, dead, hands if anybody wanted me to stop using it :-)

Custom keyboard layout for entering Latin characters

I started a Graduate Diploma in Humanities at the University of New England this year and got sick of my Open Office macro toolbars for entering special characters. So, after some googling, I decided that a custom keyboard layout would be my only salvation. So, here’s an installer created under 64-bit Windows 7 (that should work for 32-bit as well) that probably also works in Vista, I’d be willing to bet. Not sure about Windows XP, though (had to restore an Acronis image of my C: drive yesterday and I couldn’t be bothered installing XP Mode again to find out!).

Download: MF Latin Keyboard Layout.zip (250 KB)

Once installed, you’ll get to see a Language Bar at the bottom-right of your Windows Taskbar (more info here if your third eyelid just came down). Unfortunately, since Microsoft don’t regard Latin as a language anybody in their right mind would speak or use, there’s no way to change the description. So, since my main keyboard is “English (Australian)” and my custom keyboard is an adaptation of an existing keyboard layout, it’ll appear as “English (United States)” for us Aussies. This might be confusing for those in the United States, however, so Americans might prefer to download the Latin.klc file on which I based the installer, open it using the Microsoft Keyboard Layout Creator, and assign it to another language so you can at least tell them apart (maybe “Latvian”? almost looks like “Latin”).

Whenever you need to type a letter with a macron or a plain, old, accent, you first have to switch to the different keyboard in the Language Toolbar for the application you’re using. So, do that first! Then, whenever you want to get an “a” with a macron, just type a left-square-bracket before you press “a” and Bob’s your uncle: ā. This will mean that you have to press left-square-bracket twice if you actually want one of those. Similarly, to get an “a” with an accent, press the back-tick/tilde key (`~) before pressing “a”, and then you get: á. The letters I’ve enabled this way are as follows: āēīōūȳ, ĀĒĪŌŪȲ, áéíóú, and ÁÉÍÓÚ.

I also cleared out the existing dead keys in the “English (United States)” template with which I started, so this keyboard might not be for you if you want to type even more special characters. I just didn’t like the idea of turning my apostophe into a dead key! Also, the letters with macrons are actually unicode, so you’ll be typing a hybrid document, probably not into an old DOS editor, though :-) It won’t like that.

Happy accentuating and macronising!

Crappy Linux Twitter Clients

I’ve about had it with the range of Twitter clients on offer in Linux. Twitux seems capable of producing nothing but “Timeline Parse Error” messages these days, so I went looking for something else. Found two possibilities: gTwitter and Gwibber. Judging by the screenshots, Gwibber is a screen real-estate hog, so I don’t think I’ll bother with that. So that leaves gTwitter. More disappointment in store, it seems…

I install gTwitter and land at a preference window, which is fine. Entered what I thought were my credentials but they didn’t work. The gTwitter window says “Click on the Preferences button to enter username and password” but there is no such button. There’s a refresh, and a paint-brush icon in the “What are you doing?” text field, but no preferences button. I try right-clicking in the humungous top area where it says “Connection failed!” but nothing shows. The “Connection failed!” message is actually a button that loads a web page; no thanks. Clicking on the icon of a PC with two screens simply toggles the humungo-area between error message and a “Name:” label and nothing else. No sign of a “Preferences button” as advertised.

Turns out there’s an icon in the panel at the top of my screen that I have to right-click on to then get to a preferences menu! Grrr! Now since I paid the princely sum of $0.00 dollars for my Ubuntu setup, I don’t really have much recourse, but come on! It’s crapware like this that makes you wonder how Linux will ever win over the masses. I should have expected it, though, since gTwitter depends on Mono, which provides the .NET plague especially for Linux.

Oh, and now that I’ve just started Twitux one more time to confirm I got the error message right, the little bitch decides to work this time! Why on earth has it been such a right pain in the you-know-what for days on end now, and it’s only after I go flirting with another crappy Twitter client that it realises it has to put out to keep me? Crikey! Sometimes computers really piss me off!