Changing name by adding to date

Well I had such good luck with my last problem, I thought I’d try this one out to see what comments I’d get.

We publish magazines and label our PDFs like the following “005_MrJonesCorp_PHM0108.pdf”.
The “005_” refers to page 5.
The “MrJonesCorp” is where we type the name of the client.
The “PHM0108” is 3 letters for the name of the publication and then 0108 represents January of 2008.
So that seems fairly straightforward, at least to us.

If we were going to “pickup” this PDF and run it again in the March issue we would be tempted to just drop a copy of the existing PDF onto a script that would rename the suffix to _PHM0308 and be done with it.

However, we’d always like to remember where the PDF came from so that we could go back to the archive and access the original pieces of the ad in case we need to modify and we don’t have some database that would tell us that.

So, what we do is run the PDF through the new issue renamer and try to end up with a “pickup” pdf that would be named "“005_MrJonesCorp_PHM0108_PHM0308.pdf” to show that the new PDF is for the March issue, but that it came originally from the January issue. However, since the names of our clients can get pretty long to begin with, the renamer will chew letters from the back of the PDF if too long and we might end up with something like "“005_MrJonesCorp_PHM11_PHM0308.pdf” and that doesn’t tell us much so someone would have to go in by hand and cut back on the name of the client and delete the original name of the publication to ge us something like “005_MrJonesC_0108_PHM0308.pdf”. That’s time consuming and fraught with human error.

Was thinking of two ways around that.

  1. Have some type of script that would create an excel log with 2 columns, one for the old “005_MrJonesCorp_PHM0108.pdf” and next to it the one with the new “005_MrJonesCorp_PHM0308.pdf” to show what it was and what it should be called for March. How simple would something like this be?

  2. Create the original name of the PDF as something like: “005_MrJonesCorp__00_PHM0108.pdf” with the 00 showing that it was the original version of the PDF. When the PDF is dropped onto the renamer for March it would be able to alter the suffix and also be able to look at the 00 and alter it to 02. I guess by naming the new PDF “005_MrJonesCorp_02_PHM0308.pdf” it would show that even though this file is for March, it’s original ran 2 issues prior to that. And by doing this we have a fixed length to the name of the PDF so that the real suffix is not just our last 7 digits, but really the last 9 with underscores and therefore the renamer wouldn’t eat into the old code as it added the new suffix.

How simple would something like this be to create a script that would change the name to be for that issue and then do some type of math to say the difference between 0308 and 0108 is 2 and alter the 00 to 02?

Or, any other brainstorming ideas to accomplish something similar. It wouldn’t matter whether the PDF showed the difference between original and new or if the data was in something like an excel sheet, as long as the data was accessible.

Thanks in advance.

/curtis

Not to ignore your workarounds, but wouldn’t it be easier to just have the renamer cut off the name of the client instead? Here’s a script I wrote that does that.

set origName to "005_MrJonesCorporation_PHM0108.pdf"
set newMonth to 3

set astid to AppleScript's text item delimiters
set AppleScript's text item delimiters to "_"
set tis to text items of origName
set AppleScript's text item delimiters to ""
set newMonthText to newMonth as text
if (count newMonthText) = 1 then set newMonthText to "0" & newMonthText
set newMonthText to "PHM" & newMonthText & "08.pdf"
set item -1 of tis to text 4 thru 7 of item -1 of tis
set end of tis to newMonthText
set AppleScript's text item delimiters to "_"
set asText to tis as text

if (count asText) ≤ 33 then return asText --If we don't have to cut anything

set cutChars to 33 - (count asText) - 1 --The amount of characters over (negative)
set item 2 of tis to text 1 thru cutChars of item 2 of tis
set asText to tis as text
set AppleScript's text item delimiters to astid
return asText
-->"005_MrJonesCorpo_0108_PHM0308.pdf"

I’d say that the one that creates an Excel log would be useful, but probably harder than this. The other’s math isn’t that hard:

set a to "0308"
set b to "0108"
((a as number) - (b as number)) div 100

But what you want to do in the end is entirely up to you.