I started with 4 PDF files, each containing 25 pages, with each page containing 4 graphics. So, 4 x 25 x 4 = 400 images. The images are of puzzles, and the 4 PDF files represent Very Easy (VE), Easy (EE), Moderate (MM), and Hard (HH). If I use the leftmost 2 images of each of the 25 VE pages for Monday, the left 2 of EE for Tuesday, the right 2 of EE for Wednesday, etc. I end up with 350 images, 50 for each day of the week, or just about a year’s worth.
So, graphically, I have 4 25-page documents with 4 images on each page, like this:
VE: A A EE: A A MM: A A HH: A A
B B B B B B B B
Acrobat nicely lets one export cropped versions of a page, and asks whether you just want the current page or that same crop position from all pages in the PDF file. Since the graphics are all positioned the same, an export of the top left image, for instance, will give me twenty-five files, each named with the root name I enter plus a sequential prefix. E.g., VE_01.eps, VE_02.eps. Actually, I’m taking two crops for each day from each file, so I’d name the top left crops VE_Mon_A_01.eps, …, VE_Mon_A_25.eps, and the bottom left crops VE_Mon_B_01.eps, …, VE_Mon_B_25.eps. The EE file, getting Tuesday and Wednesday, would produce EE_Tue_A_01.eps, . . . , EE_Tue_A_25.eps, EE_Tue_B_01.eps, . . . , EE_Tue_B_25.eps, EE_Wed_A_01.eps, . . . , EE_Wed_A_25.eps, EE_Wed_B_01.eps, . . . , EE_Wed_B_25.eps. And so forth, for the rest of the week.
What I need to do is to have a script that will rename these .eps files, inserting the actual date they’ll be used, with the starting date set to Monday, Jan 22, 2007. I.e., what I want is something like this:
VE_Mon_A_01.eps → 070122_Mon.eps
VE_Mon_B_01.eps → 070129_Mon.eps
VE_Mon_A_02.eps → 070203_Mon.eps
. . .
VE_Mon_A_25.eps → 071224_Mon.eps
VE_Mon_B_25.eps → 071231_Mon.eps
EE_Tue_A_01.eps → 070123_Tue.eps
…
EE_Tue_B_25.eps → 080101_Tue.eps
…
HH_Sun_B_25.eps → 080106_Sun.eps
In reality, each of my 100 pages has not only 4 puzzles but also the 4 answers, making 800 files to rename. Seems like the kind of thing for which scripting is designed! My initial thought was perhaps to use a simple file-renaming program to change the two-digit sequential numbering of the A and B sets of graphics to a three digit number, with the A’s ending in zero and the B’s in five, and remove the letter code useful only for sequencing. I’d get this:
VE_Mon_A_01.eps → VE_Mon_010.eps → (10-5)/5 = 1
VE_Mon_B_01.eps → VE_Mon_015.eps → (15-5)/5 = 2
VE_Mon_A_02.eps → VE_Mon_020.eps → (20-5)/5 = 3
. . .
By subtracting 5 from the sequence number and dividing the remainder by 5, I’d get a week number, as shown above. Perhaps this could then be used to calculate the dates for the file renaming? Or perhaps just calculating a day of the year number (jan 22 = 22, obviously) based on multiples of 7 for each day starting on 1/22/07, and then calculating the date from the day of year?
Any ideas or existing code to make this easy? I can do it in Applescript, Perl, bash . . .