Page 1 of 1

How to replace a character in only part of the filename

PostPosted: Tue Sep 24, 2013 6:17 pm
by gchetta
I want to do a character replacement over a specified range of the file name, but the replacement occurs for the entire name. Is there a way to limit the replacement over a specified position range.

For example, a typical file name might be
2013 09 24 medical claim.pdf

and I want it to become
2013-09-24 medical claim.pdf

Thanks in advance for any help
Greg

Re: How to replace a character in only part of the filename

PostPosted: Tue Sep 24, 2013 7:32 pm
by Stefan
You can do that with regular expressions,

by matching the four parts of the file name (Y) (M) (D) (string) and storing that in backreferencing groups (...).

Then replace with what was matched and stored in that groups "\1 \2 \3 \4" and add hyphens yourself "\1-\2-\3 \4"

FROM:
2013 09 24 medical claim.pdf
TO:
2013-09-24 medical claim.pdf

USE:
RegEx(1)
Search: (\d\d\d\d) (\d\d) (\d\d) (.+)
Repla: \1-\2-\3 \4



.