How to replace a character in only part of the filename

Post any Bulk Rename Utility support requirements here. Open to all registered users.

How to replace a character in only part of the filename

Postby gchetta » Tue Sep 24, 2013 6:17 pm

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
gchetta
 
Posts: 1
Joined: Tue Sep 24, 2013 5:59 pm

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

Postby Stefan » Tue Sep 24, 2013 7:32 pm

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



.
Stefan
 
Posts: 736
Joined: Fri Mar 11, 2005 7:46 pm
Location: Germany, EU


Return to BRU Support