Community forum

Please note that VisualCron support is not actively monitoring this community forum. Please use our contact page for contacting the VisualCron support directly.


Frank2808
2018-10-09T20:58:29Z
Hi guys, been struggling with this. I have a PGP Encrypt task where I'm encrypting a file with the format aaaaa_bbbbb_ccccc_dddd.txt and I want to use the destination file mask to have the result be aaaa_cccc.pgp Basically I want to parse apart the incoming file name on '-' and concatenate certain parts with a pgp extension. I found several examples but for this task I can't find the variable for the current file being encrypted. Any help would be appreciated. Thanks!
Sponsor
Forum information
Gary_W
2018-10-09T21:23:00Z
Use a regular expression to capture each part of the filename into a remembered group. Then use the parts you want to keep.
Input is your filename (can be a variable). The regex uses parenthesis for remembered groups left to right and inside are 0 or more of any characters. So it can be read from left to right as remember a group of 0 or more of any characters followed by an underscore, followed by a 2nd group of the same, a third and a fourth but followed by a literal dot and the text "txt". Replace all that with the first remembered group (referenced by $1), an underscore, the 3rd remembered group, then the text ".pgp".

{REGEX(Replace|aaaaa_bbbbb_ccccc_dddd.txt|(.*)_(.*)_(.*)_(.*)\.txt|$1_$3.pgp)}

Oh to get the file name from a variable you need to know how you are getting the file name in the first place. A trigger that started the job? Previous task's STDOUT? Listing files in a folder?
Frank2808
2018-10-11T19:34:27Z
Thanks for getting back to me. Although I had figured out how to parse the file name, your solution is way better. My actual issue though is how to get the file name in the first place. The job is triggered by a time trigger and has 2 steps. First I execute a script via an Execute task to create a 4 text files then the second task encrypts those files. I can't seem to figure out how to reference the actual file name to encrypt in the destination file mask of the PGP Encrypt task.
Gary_W
2018-10-11T19:57:24Z
Do you use a loop to iterate through the files in the folder and encrypt each one? If so, as you iterate, the filename would be {LOOP(CurrentValueXLine)}. You'd use this in the pgp job.
If the file names are known and you are referencing them by filename, save the filename into a job variable first, and refer to them by the job variable in the pgp job to build the pgp file name.
Support
2018-10-12T07:41:33Z
Originally Posted by: Frank2808 

Thanks for getting back to me. Although I had figured out how to parse the file name, your solution is way better. My actual issue though is how to get the file name in the first place. The job is triggered by a time trigger and has 2 steps. First I execute a script via an Execute task to create a 4 text files then the second task encrypts those files. I can't seem to figure out how to reference the actual file name to encrypt in the destination file mask of the PGP Encrypt task.



I would recommend using a File Trigger instead of Time Trigger. Then you know exactly which file to work with because you can use the File Trigger Variables.
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
Scroll to Top