You are viewing limited content. For full access, please sign in.

Question

Question

Pattern Matching Assistance - Removing Filename from Filepath

asked on June 26, 2017

I am working on a Workflow that needs to use look-up data about a file path and apply it to files in a folder through a business process. The below screenshot shows my current token in the token editor:

I would like to use all but the filename in the file path. I have an expression that uses the first part of this, however there are varying amounts of folders before the filename.

I imagine that the right expression could ignore all characters after the last ' \ ' in the string. I am just unsure of how to write this. 

0 0

Answer

SELECTED ANSWER
replied on June 26, 2017 Show version history

You could easily do this without any pattern matching at all using a combination of functions and indexing to give you the results and flexibility you need.

 

  1. Function: Split the token on the "\" character
    • this will give an array of each piece/folder in the path
  2. Function: Remove At "-1"
    • removes the last item of the array (file name) regardless of how long the path is
  3. Apply Index: All Values Separated by "\"
    • reconstructs the file path with the remaining items

No need to worry about complex pattern matching rules, unusual conditions like spaces or special characters, or ways to deal with varying path lengths.

If you need the last "\" at the end, you can just add it after the token value.

3 0

Replies

replied on June 26, 2017

Hello Mitch,

I got something similar to work like this..

1 0
You are not allowed to follow up in this post.

Sign in to reply to this post.