Rename files using your favorite text editor

When renaming lots of files you usually resort to your typical for f in … command line with a sed command or similar included, or perhaps you use rename(1) but sometimes it’s just easier if you can use your normal editor. In my case this is vim, where I can then use various nice things such as changes on blocks, or just ad hoc changes to the file names. To accomplish this in an easy way I use an old quick hack; which is the following script that I’ve named viren:

#!/bin/sh

# viren
# Rename files using an editor (vim in this case)

FNEW=`mktemp -t`
FORIG=`mktemp -t`
FCMDS=`mktemp -t`
for i in $*
do
        echo "\"$i\"" >> $FORIG
done
cat $FORIG > $FNEW

vim $FNEW

wcn=`wc -l $FNEW | cut -d\  -f1`
wco=`wc -l $FORIG | cut -d\  -f1`

# go ahead if the line count is the same
if [ $wcn -eq $wco ]
then
        paste $FORIG $FNEW | sed -e 's/^/mv /g' > $FCMDS
        source $FCMDS
        echo Renamed/moved files
else
        echo Aborted rename/move
fi

rm $FNEW $FORIG $FCMDS

Move files to directories based on modification time

Here’s a really simple shell script to move files to directories named based on the modification time of each file. It uses only the date and the script also accepts an optional first argument to set a suffix for each directory. I sometimes use this as a first step when I organize photos and videos, the suffix is set to the source of the files (user-device in my case, eg ckk-40d if it’s from my Canon 40D), I then manually add a short description to the end based on the directory contents. Most commonly applied when I empty the card from my point-and-shoot.

#!/bin/sh

# Put files on command line in one directory per date (based on mtime) with the
# suffix given by the first optional argument on the command line

if [ ! -n "$1" ]; then
   echo "Usage:"
   echo "$0 [suffix]  ... "
   exit
fi

if [ ! -f "$1" ]; then
  suffix=$1
  shift
fi

while [ -n "$1" -a -f "$1" ]; do
  mdate=`stat --printf "%y" $1 | cut -d\  -f1`
  mkdir -p $mdate$suffix
  mv -v $1 $mdate$suffix
  shift
done

Making snoot grids

I’ve been playing around with some flash based lighting for quite a while now, but as I rarely have access to larger studio flashes I’m going the Strobist route. I have had a Sigma EF-500 Super for some time now and have recently purchased a few Westcott umbrellas and two Manfrotto 001B light stands. I need another flash as well, probably a Sigma EF-530 Super, but I’m still considering my options.

Meanwhile I want to start experimenting some more. Two things that I really wanted to try was the effect of putting a gel on the flash and other ways to restrict the light apart from snooting. I bought both a color correcting and an effects gel pack from flashgels.co.uk. And a really effective way to restrict and control the output from a flash is to use a snoot or a snoot grid. The inspiration for this small DIY project comes from the Strobist blog and the post DIY: Black Straws Snoot Grid (Part 1) from the lighting mods blog.

It doesn’t matter very much if the pieces of straw aren’t the exact same, but it’s extremly tedious work. After testing a few other items I found a tea candle holder that helped me quickly cut the straws into 20 mm pieces and then after some thinking I grabbed a toilet paper roll from my recycling bin and cut it to assist with the 50 mm pieces. The glue I used is a pretty convenient gel glue that doesn’t make a mess compared to traditional glues that tend to get thin threads of glue all over the place. While waiting for the glue to dry I also took the opportunity to use some leftover cardboard to make a new normal snoot. I used the pieces for the grids as a template, glued the ends and then covered it with black duct tape. At one of the ends I put small velcro dots (that came with the flash gels) which prevents the snoot from falling off the flash. I could have made a tighter version instead but this worked out pretty good actually. You can also fold it flat for storage and transportation.

The grids finally got finished and I wrapped them in black tape. I took a few crappy pictures with my Canon 860IS during the project:

And here’s a few test pictures taken with the Sigma flash off camera triggered by my cheap ebay radio trigger and using my Canon 350D with a EF 17-40L. The camera was kept in approximately the same place and with the exact same exposure setting to better show the differences; ie the more you control the light the more light you lose. I put a colored gel on the flash to make it easier to see the pattern of the light on the wall:

_MG_0622
50mm snoot grid

_MG_0624
20mm snoot grid

_MG_0626
normal snoot

_MG_0628
no snoot

I then found a highly cooperative model to check the effect of the snoots on something other than a wall. Same camera and lens, still in approximately the same distance from the object and all with the same exposure setting. The amount of control is amazing!

_MG_0632
50mm snoot grid, no spill on the background at all!

_MG_0633
20mm snoot grid, some very minor spill

_MG_0634
normal snoot, lots of spill

_MG_0635
no snoot

Wii – First Impressions

Today my perseverance finally paid off, I managed to get hold of a Nintendo Wii! Unfortunately they were out of extra remotes but at least I got a copy of the new Zelda game as well. After getting everything connected, setting up the wireless network connection and letting the small box update itself I played around a bit with the Wii Shop and the Opera browser, which actually works remarkably well for browsing on a (non-HD) TV.

Then I inserted the Wii Sports disc.

It’s now 2 hours later and I realized that I’m hooked already. Baseball and Golf sucks. Boxing wasn’t as much fun as I thought, but it will probably help if I can figure out the controls properly instead of madly waving the remote and nunchuck in the air and getting smacked in the face by the cable… But Bowling is great and Tennis is brilliant! Normally playing any computer or console games isn’t something I do very often. I have an Xbox but it’s rarely used for anything else than Xbox Media Center (which really rocks BTW), but I definitely enjoyed playing on the Wii! The closest experience to the Wii that I’ve had before is probably Dance Dance Revolution. Someone could create completely insane stuff if they were to combine a dance mat with the Wii remote and nunchuck…

Tomorrow I’ll try to find a copy of Rayman Raving Rabbids and another remote, there seems to be a few of each in stock in some stores close by so I have high hopes. And of course I’ll have to spend some time with Zelda as well, but it might not be until Sunday since Saturday is almost fully booked with other activities.

The Wii concept is so far at least a 9 on a scale from 1 to 10! I have high hopes for Rayman, it seems like it could be quite a crazy multi-player game!