August 2011 Archives

Another script to rename files

programmer_mug-p1682924711369532772ln8f_400.jpg I'm posting another small script to rename files.

I'm working on files with spaces in their name (Oh! The Evil!) and I need to rename them to remove spaces and conver in camel-case.

At this time, I chose Python (version 3) to guarantee the script works also on Windows.

Just create a file called (for example) ToCameCase.py and past into it:

#!/usr/bin/env python3

import sys
import os

if len(sys.argv)<2:
    print("Indicate the file pattern, please")
    exit()

for filename in sys.argv:
    name_tokens = filename.split(" ")
    new_name=""
    for token in name_tokens:
        new_name+=token[0].upper()+token[1:]

    os.rename(filename,new_name)

From the console call the script passing to it the file name o pattern to rename. For example

 ToCameCase.py *.obj

it will convert the name of all the OBJ files in the directory.

Just a warn: it is very simple and only-for-my-usage oriented, so be careful if you use it: read the code and test it before use on your files!

Upgrading to kernel 3 and the sed story of Grub error 15

P1000074-(Small)-754189.JPG Calm down: this is an happy-ending story.

I've recently upgraded my Archlinux machine to linux kernel 3.0.

After that, obviously, I haven't be able to boot my machine because Grub claim the error 15 (file not found). Anyway the workaround is easy. The problem is in the naming convention for the kernel images. It is different in the new release respect of the old one: the vmlinuz2XX is now vmlinuz-linux and the initrd-2.XX.img is now initramfs-linux.img.

This post could be useful.

So when the Grub menu shows up you can press the 'e' key and edit the item to change the name of files. After, boot the system by hitting the 'b' key.

...and remember to properly reconfigure Grub (or (Grub2)[https://wiki.archlinux.org/index.php/GRUB2]) before restart linux again... this is a reminder for myself, obviously.

Writers use Emacs...

hemingway.jpeg ...maybe.

I'm collecting some interesting reference about Emacs for writers. I want highlight two post here.

The first is Let's just use Emacs By Urpo Lankinen. He describes exactly my feeling about writers' tools and it faces the Scriveners dilemma (buy it, don't buy it). The post convinced me (I was already convinced actually) that Emacs could be a good tools to write novels.

Anyway a big doubt still stays into the deepest part of my soul: Emacs could be a distracting tool. Yes, I know, Emacs is (could be) a minimalist tool and it boosts your writing speed and it helps you to focus on your work and... and... and... but you have to learn it before to gain any sort of advantage form it. If you aren't a Emacs pro, you'll loose a lot of time in trying to be a pro. The main advantage of Scrivener is that you already know all you need to write and you can optimize your performances by learning tips and tricks day by day. To be clear, my suggestion is take your time to learn Emacs, anyway. This because some day in the future you'll wake up and latest Scrivener release will be full of feature that you'll never use (please Keith don't!) and the research of the perfect novelist tools will start back again...

The second post that I want link here is Writing in the Age of Distraction by Cory Doctorow. I quote, in toto, this post.

I'd linke to mention also The Woodnotes Guide to Emacs for Writers by Randall Wood. I suspect that the document is not fully update but it suggests good hints.