Sunday, August 20, 2006

Homebrew scripts

Hi there, long time no blog.

This is a short post to introduce two home made scripts. They're not terribly useful, but I do happen to use them often and I've been asked in the past to share them, so I thought I might as well do it here (assuming people still read this blog...).

Anyhow, both are python scripts, but only the first one is truely cross platform, though the second one could be changed to be so too.

numericnames

This script renames files in folders and subfolders (recursively) to follow a numeric naming scheme. That is, all files in a folder will be renamed to FOLDERNAME00000.extension, where FOLDERNAME is the name of the folder in question, 00000 is a numeric sequence and extension is the extension of the file. The numeric sequence is basicly a padded count of the files in the folder. If you have 10 files, the sequence will be 01, 02, 03, ... The script takes into account deleted files (filling the empty slots when renaming) and increases the padding size when needed. I mostly use this script on images folder, usually photos or the like when I don't really care about the name of the file but still want to give them a meaningful base name (the name of the folder).

wallpaper

This script is basicly a wallpaper management tool. It requires KDE and pyKDE's DCOP access to change the wallpaper, but it could be changed to use some Gnome method, win32 method or whatnot.
It takes a source directory (with possible subdirectories), supports different operations: changing the wallpaper randomly, changing and deleting the current wallpaper, changing to (or one of) the latest wallpaper(s), running a renaming script (I use numericnames for that). You can specify a pattern to use only a subdirectory of the source folder. The script uses a simple config file (which it locates next to its own location) to define source directory and default operation. The config file is generated on first run.

Hopefully, those could be useful to someone else too.

Martin