I need help if someone can come up with a script that I can use in Switch to edit ink preset header.
We are sending PPF files (Cip3 ink preset) to Pecom for Rotoman.
For some reason Pecom can read only data inside the header of the PPF file and only from tag /Cip3AdmJobName
We use Printready workflow that writes only docket number into that tag, and writes sheet name into /Cip3AdmSheetName tag.
I would need to append this sheet name into Admjobname tag to get complete proper name of the signature that Pecom understands.
Attached is screenshot of how it looks and how it should look.
I googled everywhere and can't find solution.
ManRoland says that is the only way they can read tag, Heidelberg has setting for writing different tag, but it screws up names of the layout, etc..
I figure custom solution would be the best.
Thanks in advance.
Need script for replacing string in file
Re: Need script for replacing string in file
I can think of a few ways to accomplish this, but I think the most straightforward way would be to load the contents of the file as an array of lines lines like this:
Then, loop through the lines until you find the line with the starting tag you're looking for. Then, append the needed values together and use File.write to write them into a file you send out of the script.
Code: Select all
// Construct File object
var file = new File( job.getPath() );
/// Open file as read only
file.open( File.ReadOnly );
// Create an array of the lines of the file
var file_as_array = file.readLines();
// Close the file
file.close();
Chat: open-automation @ gitter
Code: open-automation & dominickp @ GitHub
Tools: Switch, Pitstop, EPMS, Veracore, PageDNA, SmartStream, Metrix
Code: open-automation & dominickp @ GitHub
Tools: Switch, Pitstop, EPMS, Veracore, PageDNA, SmartStream, Metrix
Re: Need script for replacing string in file
Can be done with scripting I guess, how is your experience with that?
I would read the /CIP3AdmJobName line and take the part after ( and before ), same for the /CIP3AdmSheetName.
Loop through the lines, and if /CIP3AdmJobName is on the line simply replace it.
I'll check some of my scripts where I do something similar..
Edit: Haha, I should not leave my posts idling for a couple of hours before hitting submit.. So, what Gabriel is saying
I would read the /CIP3AdmJobName line and take the part after ( and before ), same for the /CIP3AdmSheetName.
Loop through the lines, and if /CIP3AdmJobName is on the line simply replace it.
I'll check some of my scripts where I do something similar..
Edit: Haha, I should not leave my posts idling for a couple of hours before hitting submit.. So, what Gabriel is saying

Part of my playground:
- HP Indigo 10k, HP Indigo 7600's (full options), Highcon Euclid III, Zünd S3
- HP Production Pro 6.0.1, HP Production Center 2.5.1 beta, Apogee 9.1, Enfocus Switch 13u1 & PitStop Server 13u2.
Chat: open-automation @ gitter
- HP Indigo 10k, HP Indigo 7600's (full options), Highcon Euclid III, Zünd S3
- HP Production Pro 6.0.1, HP Production Center 2.5.1 beta, Apogee 9.1, Enfocus Switch 13u1 & PitStop Server 13u2.
Chat: open-automation @ gitter
Re: Need script for replacing string in file
Great minds think alikesander wrote:Edit: Haha, I should not leave my posts idling for a couple of hours before hitting submit.. So, what Gabriel is saying

Chat: open-automation @ gitter
Code: open-automation & dominickp @ GitHub
Tools: Switch, Pitstop, EPMS, Veracore, PageDNA, SmartStream, Metrix
Code: open-automation & dominickp @ GitHub
Tools: Switch, Pitstop, EPMS, Veracore, PageDNA, SmartStream, Metrix
Re: Need script for replacing string in file
Thanks guys, it is over my head but I will try to sit down and decipher what you are telling me 

Re: Need script for replacing string in file
Can you get me that ppf?
Maybe, don't pin me on it, I can play around with it if I have some spare time.
Maybe, don't pin me on it, I can play around with it if I have some spare time.
Part of my playground:
- HP Indigo 10k, HP Indigo 7600's (full options), Highcon Euclid III, Zünd S3
- HP Production Pro 6.0.1, HP Production Center 2.5.1 beta, Apogee 9.1, Enfocus Switch 13u1 & PitStop Server 13u2.
Chat: open-automation @ gitter
- HP Indigo 10k, HP Indigo 7600's (full options), Highcon Euclid III, Zünd S3
- HP Production Pro 6.0.1, HP Production Center 2.5.1 beta, Apogee 9.1, Enfocus Switch 13u1 & PitStop Server 13u2.
Chat: open-automation @ gitter
Re: Need script for replacing string in file
Sure, here is link to Sig 1 front and sig 2 front, just in case so you can see the difference:
---
https://dl.dropboxusercontent.com/u/777 ... ig-1_F.ppf
https://dl.dropboxusercontent.com/u/777 ... ig-2_F.ppf
---
https://dl.dropboxusercontent.com/u/777 ... ig-1_F.ppf
https://dl.dropboxusercontent.com/u/777 ... ig-2_F.ppf
Re: Need script for replacing string in file
I am very close, I feel it
but need some more help.
I constructed a script using other snippets and some magic that works beautifully online on regex1o1.com site, however it is giving me parsing error in Switch scripter.
If you want to check 1o1 example that works: https://regex101.com/r/5SqNds/2
This is my code:
It gives me parsing error in line 6, which is var subst = `\$1\$2-\$5\$3\\n\$4\$5`;

I constructed a script using other snippets and some magic that works beautifully online on regex1o1.com site, however it is giving me parsing error in Switch scripter.
If you want to check 1o1 example that works: https://regex101.com/r/5SqNds/2
This is my code:
Code: Select all
var regex = /(\/CIP3AdmJobName *\()([^\)]+)(\)[^\n]+)\n([^\(]+\()([^\)]+)/g;
var subst = `\$1\$2-\$5\$3\\n\$4\$5`;
var extension = s.getPropertyValue("Extension");
var tempFile = job.createPathWithExtension(extension);
var myFile = new File(tempFile);
var InputPath = job.getPath();
var inputFileText = File.read(InputPath);
var outputFileText = inputFileText.replace(regex, subst);
myFile.open( File.WriteOnly | File.Truncate );
myFile.writeLine(outputFileText);
myFile.close();
job.sendToSingle(tempFile);
job.sendToNull(InputPath);
Re: Need script for replacing string in file
It seems that you're using back ticks (`) when you should be quoting strings with (") or ('): http://eslint.org/docs/rules/quotesZoranj wrote:It gives me parsing error in line 6, which is var subst = `\$1\$2-\$5\$3\\n\$4\$5`;
Chat: open-automation @ gitter
Code: open-automation & dominickp @ GitHub
Tools: Switch, Pitstop, EPMS, Veracore, PageDNA, SmartStream, Metrix
Code: open-automation & dominickp @ GitHub
Tools: Switch, Pitstop, EPMS, Veracore, PageDNA, SmartStream, Metrix
Re: Need script for replacing string in file
I tried but if I use single quote, this is the result (it removes my JobAdmSheetName completely and CIP3JobAdmName
---
---
If I use regular quotes, this is the result:
----
---
Code: Select all
CIP3BeginSheet
/CIP3AdmJobCode (686708) def
$1$2-$5$3\n$4$5) def
%No TypeOfScreen
If I use regular quotes, this is the result:
----
Code: Select all
CIP3BeginSheet
/CIP3AdmJobCode (686708) def
$1$2-$5$3\n$4$5) def