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

Question

Question

pattern match to rename from folder path

asked on November 17, 2023

I need to rename a bulk of files.  The new name of the document needs to be the same as the folder from which it resides in. I need a pattern match that will capture just the final folder from multiple paths. 

 

Path examples:

 

\Planning\General Files\Planning Staff\Monroe\Vouchers\2023 Misc\Billboards\Payment 4 - Inv. 12345

\Engineering\Correspondence\2023\07-26-2023 Eagle Appeal

 

How do I capture things only after the final backslash?

 

 

0 0

Answer

SELECTED ANSWER
replied on November 17, 2023

Tested on regex101.com: 

([^\\]+$)

 

Explanation from regex101.com: 

1st Capturing Group ([^\\]+$)
Match a single character not present in the list below [^\\]
+ matches the previous token between one and unlimited times, as many times as possible, giving back as needed (greedy)
\\ matches the character \ with index 9210 (5C16 or 1348) literally (case sensitive)
$ asserts position at the end of a line

 

0 0
replied on November 17, 2023

Worked like a charm.  Thanks so much!

1 0

Replies

You are not allowed to reply in this post.
You are not allowed to follow up in this post.

Sign in to reply to this post.