Substring of job name to Action list fields.

Post Reply
jstotz
Newbie
Posts: 14
Joined: Thu Jan 22, 2015 7:47 pm

Substring of job name to Action list fields.

Post by jstotz »

I'm wondering if this is possible and if so, where to start.
1 - The job is a folder containing a text and cover pdf.
2 - Read a job name and extract a substring from it. (Number of pages)
3 - Later in the flow, run several Pitstop actions that do things like resize the page, move elements on the page, and draw crop marks. (I'm adding a spine to a cover file based on the number of text pages.)

I already have most of this working, but I have a separate flow for each possible number of pages and spine width. The actions have the appropriate numbers hard coded into them.

I would like to get the number of pages out of the file name, do some math on it and put these numbers into the actions for things like how far to move stuff and where to draw the marks, etc. This would allow me to have one flow that will handle any number of pages.

I assume that variables are involved, but I don't know how to get the file name substring into a variable and do the calculations later. Is this doable without scripting?
Thanks
User avatar
magnussandstrom
Advanced member
Posts: 547
Joined: Thu Jul 30, 2020 6:34 pm
Location: Sweden
Contact:

Re: Substring of job name to Action list fields.

Post by magnussandstrom »

You already have access to the number of pages in a PDF as soon as the file is picked up by a Switch flow. This information is available via the metadata variable [Stats.NumberOfPages], so there’s no real need to extract the page count from the file name unless you specifically want to.

However, it’s not possible to use Switch variables directly inside a PitStop Action List. To make a Switch variable available in PitStop, you need to pass it through using a Variable Set.

To do this:

1. Select a PitStop Server Configurator in a Switch flow
2. Go to Variable Sets and click New
3. Create a new Variable Set (it can contain multiple variables)
4. Add a new variable and set Type to Text with variables
5. In the Variable Value field, insert your Switch variable (for example, [Stats.NumberOfPages])

Now go to your Pitstop Action > Actions > Enable variable Names

Once this is set up, the variable will be available for use inside your PitStop Action List.

switch_pitstop_variable_set.png
switch_pitstop_variable_set.png (54.3 KiB) Viewed 217 times

pitstop_variable_name.png
pitstop_variable_name.png (54.73 KiB) Viewed 217 times
jstotz
Newbie
Posts: 14
Joined: Thu Jan 22, 2015 7:47 pm

Re: Substring of job name to Action list fields.

Post by jstotz »

I already have an applescript that figures out the number of pages because it is rather complicated so I'll stick with that for now.

I made a dummy flow and set up one variable to pull the number of pages out of the file name and an action that used that number. That worked, although I had trouble with the regex.

Then I added the other calculation variables and the actions that use them and I'm getting an error from Pitstop server that says:
349: Error while processing document (PitStop Library error code 3504): An error occurred while calculating the values of a required variable.
Is there any way to find out which variable is the problem?

The regex problem is that there doesn't seem to be a way to tell it to use a group, only the full match.
[Job.NameProper:Search="_(\d{3})_"]
file name is: 56789_123_text.pdf
I'm trying to get the "123", not the whole "_123_"
I've temporarily changed the file name to have spaces instead of underscores.

Thanks
User avatar
magnussandstrom
Advanced member
Posts: 547
Joined: Thu Jul 30, 2020 6:34 pm
Location: Sweden
Contact:

Re: Substring of job name to Action list fields.

Post by magnussandstrom »

There is probably a better way to do it, but my take (if I didn't have the Scripting Module) would be a two step solution using private data:


Folder 1 Private data:

pageNo=[Job.NameProper:Search="_(\d{3})_"]

Folder 2 Private data:

pageNoTrue=[Job.PrivateData:Key="pageNo",After="_",Before="_"]

Now you have 123 in the variable [Job.PrivateData:Key="pageNoTrue"]
freddyp
Advanced member
Posts: 1173
Joined: Thu Feb 09, 2012 3:53 pm

Re: Substring of job name to Action list fields.

Post by freddyp »

jstotz
Newbie
Posts: 14
Joined: Thu Jan 22, 2015 7:47 pm

Re: Substring of job name to Action list fields.

Post by jstotz »

Thanks for the tips on the regex. Do you have any ideas on the variable error?
349: Error while processing document (PitStop Library error code 3504): An error occurred while calculating the values of a required variable.

I know it's not caused by the _123_ because I'm temporarily using spaces in my file names instead of underscores and that part works ok. I think it has to do with the calculated variables.
Screenshot 2026-01-16 at 9.02.37 PM.png
Screenshot 2026-01-16 at 9.02.37 PM.png (13.07 KiB) Viewed 128 times
User avatar
magnussandstrom
Advanced member
Posts: 547
Joined: Thu Jul 30, 2020 6:34 pm
Location: Sweden
Contact:

Re: Substring of job name to Action list fields.

Post by magnussandstrom »

Maybe you can post a sample flow where the error occurs?
Post Reply