View previous topic :: View next topic |
Author |
Message |
harterlynn
Joined: 29 Jun 2008 Posts: 3
|
Posted: Sun Jun 29, 2008 3:33 pm Post subject: Moving file extension to the end of file name. |
|
|
I am new to regular expressions and I am using PKFRANK to rename a long list of files. Could anyone help me out with the syntex for the regular expression to do the following.
How to move file extension to the end of file name using a regular expression.
Using Search Pattern: REGEX.
This is an example of a file name I want to rename:
AP JOURNAL.RTF - APRIL 07
TO
AP JOURNAL - APRIL 07.RTF
Also, how to define an "OR" statement in a search pattern?
APRIL OR APR |
|
Back to top |
|
|
admin Site Admin
Joined: 09 Mar 2007 Posts: 448 Location: Canada
|
Posted: Mon Jun 30, 2008 12:45 pm Post subject: |
|
|
Try the following (when pasting to the search/replace column, do not paste the single quotes as they are for highlighting only):
Row: 1
Search: '(.*?)([.].*?)([ ].*)'
Replace: '\1\3\2'
This will isolate the extension in the second group and move it to the end.
After using the above do you still need to use the OR pattern? If you do then let me know with some example before/after names.
Peter. |
|
Back to top |
|
|
harterlynn
Joined: 29 Jun 2008 Posts: 3
|
Posted: Mon Jun 30, 2008 3:43 pm Post subject: REPLY |
|
|
Thank you Peter for the reply.
I will try this solution when I get home tonight.
Conserning the OR statement.
Search for this: (This is where I need the OR Statement.)
APRIL, April, APR, Apr
Replace with:
04-08
Thank you for all the help. |
|
Back to top |
|
|
admin Site Admin
Joined: 09 Mar 2007 Posts: 448 Location: Canada
|
Posted: Mon Jun 30, 2008 4:18 pm Post subject: |
|
|
The '|' character is used to set up an OR expression.
To change variations of 'April' to '04-08' add the following to the second row (again don't include the single quotes):
Row: 2
Search: 'APRIL|April|APR|Apr'
Replace: '04-08'
Hope this helps!
Peter. |
|
Back to top |
|
|
harterlynn
Joined: 29 Jun 2008 Posts: 3
|
Posted: Mon Jun 30, 2008 5:56 pm Post subject: |
|
|
Thank you for the help.
Your answers where great.
I hope to learn a great deal more about Regular Expressions in the near future.
Thanx's again. |
|
Back to top |
|
|
|