RegEx Rename job

Post Reply
jdold
Newbie
Posts: 1
Joined: Tue Feb 26, 2019 6:43 pm

RegEx Rename job

Post by jdold » Thu Mar 14, 2019 9:30 pm

I could use a little help with an email flow.

Trying to watch an email and create folders on a server named the email subject-email sender-email date. and download all attachment into them.
Also, unzip any zipped files and put original zip in original zip folder inside that hierarchy.
I can do that but the problem comes in when the subject has special characters,
Then it will not create a folder and become a problem job.
Found some help in this post- viewtopic.php?f=13&t=2214&p=7657&hilit= ... ject#p7657
I put that script in my rename job under - replace by- regexpression defined.
That will remove those characters,
but the problem is now, have lost other email info and cannot name folders as I originally wished.
Another issue is now when I dismantle the job to get the zip file and set hierarchy, and then Archive hierarchy I get a folder for every piece in original job.

Too much to wish for?

mclarke
Member
Posts: 37
Joined: Thu Feb 28, 2013 5:29 pm
Location: Syracuse, NY

Re: RegEx Rename job

Post by mclarke » Thu Mar 21, 2019 2:55 pm

Try setting the data you need to private data items as soon as the job comes in. Run the script on just the private data item that contains the special characters. The rest should not be touched.

With the most recent version of Switch. there is an option in the folder properties to set private data items, so you don't need a special script for setting them. The syntax is

key=value (one key per line). The value can be a job variable such as the email address, subject, etc...

In your script doing the replacement, you will now reference the private data key and change it.

Also, your Rename job element should reference a script expression, not a regex. You do the work in the script expression and return the result as the new name.

Post Reply