kc27
Joined: 23 May 2007 Posts: 9
|
Posted: Fri May 02, 2014 5:15 pm Post subject: Keep first 5 Characters, Add Text, and Keep Ext? |
|
|
Hi
I have files named like this: "08749 description of file contents.pdf"
My goal is to keep the five digit number, add the letters "fa" after the number, and keep the ".pdf" extension. So the above file would become "08749fa.pdf"
Ive figured out how to add the letters "fa", but cannot figure out how to delete the "description of file contents" portion of the file name.
Can someone give me some ideas on this? Thanks in advance for your time.
UPDATE:
I got this figured out - below is what I used in case this is useful to someone else. There are probably more elegant ways to accomplish this using PFrank, but this worked for me.
Row 1 Search Pattern:
(?x)(^.{1,5})(.*) # Insert the text: 'myText' after position 5
Row 1 Replace Pattern:
\1fa\2
Row 2 Search Pattern:
(?Ex)^(.{1,7}).*$ # keep 1st 7 chars in prefix
Row 2 Replace Pattern:
\1 |
|