View Single Post
Old July 6th, 2022, 11:35 AM
ReminderVDP ReminderVDP is offline
Regular Contributor
Join Date: Jan 2013
Location: King of Prussia, PA
Posts: 138
Default Reg Ex or Javascript for File Name

I've got a rule in a file that looks for a PDF on a server in a folder based on the file name. It's looking for the file based on a field in my data but I'm adding two zeros in the rule because the data field does not contain the zeros.

For example, the data field has "9" in it. The file it is looking for has "009" in it. My current rule is this:
var issueNumber = 'GH00' + Field("MagIDShort");

var pathName = "X:\\EDITORIAL\\FinalGutsforProofs\\GHM\\";
var FullResourcePath = pathName + issueNumber + "\\" + 'GH_magazine-00' + Field("MagIDShort") + ".pdf"; //change to match your data file field
var x = new FusionProResource(FullResourcePath, "graphic", 1);
if (!x.exists)
ReportError("Graphic not found: " + FullResourcePath);
var pdfString = '';
var pages = (x.countPages);
for (var pgnbr = 1; pgnbr <= pages; pgnbr++)
x.pagenumber = pgnbr;
pdfString += x.value + '<p>\n';
Print("Result is: " + pdfString);
return pdfString;
It adds the two zeros in line 4. However, we are coming up on issue 10 so I will only need to add one zero to the rule, but I still have people making files looking for issue 9 and still need the two zeros in the file name.

Is there some reg ex that would look for one or two zeros? I'm not good at reg ex so I'm looking for a solution that can be used for either file name, 009 or 010. Thanks in advance.
Bryan Mathes, Print Production Specialist
FusionPro Designer 10.1.11, FusionPro Producer (Server) API 10.1.11
Mac OSX 10.12.6
Mac Pro 2.8 GHz Quad Core Intel Xeon
Reply With Quote