I know, I know… I give too little. If I made new year resolutions – well never mind. There has been considerable space-time since I last posted.
I started off my Summer biking to work at Hush over in DUMBO. Was the greatest [bike] commute of all my time. While on tour at Hush I was able to meet some great folks doing fantastic new media work. “Creative programming” is the future folks. Wish I could have spent more time there. Was only able to get my feet wet with this spot. Rented Houdini for the 3D. Composited in After Effects (which I didn’t do).
I did a little gig at Imaginary Lice… er, Forces which I won’t mention other than they don’t have enough good lunch spots around the facility. (Which is critical in choosing the facilities you want to freelance for in NYC).
For the last few months I’ve been locked up at The Framestore on a film titled, “The Secret Life of Walter Mitty”, due out next summer. Sorry no pictures yet.
As good as it’s been I have move on. In fact, I’m moving to Seattle, Washington! That’s right – and – *gasp* I’ll be working for Microsoft. All I can say about this is that I’m thrilled to be working with the team that brought you the Xbox Kinect.
“And if I’m the man, Then you’re the man, and
He’s the man as well…”
I’m going to come at you today with a very common situation. Renaming a series of files, bash and GNU utils style. This applies to something as trivial as importing my camera photos which typically gives me a bunch of files named IMG_2042.JPG, IMG_2043.JPG, IMG_2044.JPG and so on. I’m here to show you how to deal with that.
We’re gonna tackle this ground up. Firstly, I need a way to increment a number. seq is our tool.
seq -f %04g 1 3
Sexy huh? We’ve already have a major building block right here. Let’s dissect this quickly. The ‘-f’ tells seq that we want a specially formatted list of numbers. In our case, zero padded numbers, at least 4 wide (%04). The letter ‘g’ gets replaced the current number in the following range (1 thru 3 in our case). If you don’t have padded numbers you can omit the use of ‘-f %04g’ altogether. The last two arguments are the range to start and end.
seq 1 3
Sweet, now we have way of representing pretty much any sequence of numbers, thanks seq! Now let’s tackle looping over this sequence of numbers and use them for renaming using a simple ‘for’ loop. In our case below the letter ‘n’ will get the results of the seq command.
for n in $(seq -f %04g 2042 2044) ; do mv IMG_$n.JPG utah.$n.jpg ; done
`IMG_2042.JPG' -> `utah.2042.jpg'
`IMG_2043.JPG' -> `utah.2043.jpg'
`IMG_2044.JPG' -> `utah.2044.jpg'
That one-liner is so unbelievably flexible (replace `mv’ with `cp’ or `ln’ for instance) it will probably be your number one oft used idiom while working with bash in production. As a matter of fact, pretty much every thing I do is looping over a list of things – yum, sounds lispy.
Well, I never played anything but softball when I was in 2nd grade or something, yet somehow I’ve managed to find myself on holy ground at second base in the new Yankee’s stadium. And the majority of my teachers never thought I’d get anywhere (except for Judy Hemphill).
If you’re wondering WTF, well let me explain. Apparently you can’t actually make a commercial starring the Yankees and film at the stadium. You have to take an awesome ferry to Staten, shoot them there and fill in the stadium later in post. So, somehow, I got to be the lucky guy let onto the field to take reference photography. Unfortunately, I couldn’t take a tri-pod out with me as the turf is worth more than the GDP of small countries or something.