My Git Book Writing Blog

Handling Picture Files

There are over 330 figures and screen shots in this book. I know because not only did I make the figures or take the screenshots, I also had to rename these files.

When I first started this project, and I had to draw a figure or take a screenshot, I saved the corresponding file into something that made sense to me at the time. For example, figure 1 in chapter 1 is from a file named single_point_of_contention.png. Easy enough!

But a few chapters later, I learned that the production process demands that all figure and screen shot files follow the convention CC_NN. CC is for chapter, and NN is for the figure number in that chapter. So single_point_of_content.png had to be renamed 01_01.png. Again, easy enough: a renaming exercise.

However, I realized I had a severe issue after I learned I needed to renumber certain chapters and figures. This does happen in the editing process. 01_01.png might end up being 02_01.png. Or vice-versa! It led to a momentary bit of insanity. I realized I needed a script that could do the renaming on-demand.

The first few lines of that script:

1
2
3
4
5
6
# Chapter 01 - Before You Begin 
cp single_point_of_contention.png image_dir/01_01.png # Frowny faces
cp distributed.pngimage_dir/01_02.png # Happy faces
# Chapter 02 - An Overview of Git and Version Control
cp vc-personal.png image_dir/02_01.png # Revs not Vs
cp vc-personal-with-saves.pngimage_dir/02_02.png

With this convention, I still save files with an easy-to-remember name, but when I need to rename them, I run the script and generate the correctly named files. Any renumbering can be done by editing the script. (Unfortunately, it’s not as easy in a Word document. Renumbering figure captions was a tedious slog.)

I haven’t had to deal with actual production folks yet, but I’m hoping this saves my sanity about a month from now!

Thank You everyone, for reading.

There won’t be a BLOG post next week, due to the American holiday known as the Super Bowl.