View previous topic :: View next topic |
Author |
Message |
jaae
Joined: 27 May 2008 Posts: 3
|
Posted: Tue May 27, 2008 2:45 pm Post subject: Regular expression that matches, except |
|
|
Hi, This is my first post on this forum. I'm trying to write a multi-line set of rules for file renaming. I got stuck with this particular problem:
I'm using ' - ' as a delimiter between e.g. artist - title, but all other instances of '-' should be removed and replaced by spaces. I've tried to use [^( - )] but have had no success so far. I'm all out of ideas. Any help would be greatly appreciated. |
|
Back to top |
|
|
admin Site Admin
Joined: 09 Mar 2007 Posts: 448 Location: Canada
|
Posted: Wed May 28, 2008 3:47 am Post subject: |
|
|
It would be useful to know what distinguishes the dash between the artist/title from the other dashes in the name.
I'll assume that the first dash is the one between the artist/title and that you want to replace all other dashes with spaces. To do this, enter the following info into the custom creator renaming list (don't include the single quotes):
Row: 1
Search: '(?1)-'
Replace: 'xyzzz'
Row: 2
Search: '-'
Replace: ' '
Row: 3
Search: 'xyzzz'
Replace: '-'
The first row is used to convert the first dash to a unique string.
The second row replaces all remaining dashes with spaces.
The third row replaces the unique string from row 1 with a dash.
Hope this helps! IF not, then please provide some specific examples of before/after names.
Peter. |
|
Back to top |
|
|
jaae
Joined: 27 May 2008 Posts: 3
|
Posted: Wed May 28, 2008 1:25 pm Post subject: |
|
|
I'm sorry for being unclear about what I'm looking for.
What distinguishes the delimiter between artist/title is the sequence: space-dash-space.
This mostly occurs just once, but sometimes more, and all instances have to remain unchanged.
ex:
10cc - I'm Not In Love.mp3
Amy Winehouse - BtB 05 - Back to Black.mp3
The other instances of the dash can occur in various combinations, such as --,---, or - - , and many more
ex:
Arid - Life--.mp3 --> Arid - Life.mp3
Beach Boys - Kokomo_- - -.mp3 --> Beach Boys - Kokomo.mp3
David-Gray - 03 - My Oh My.mp3 --> David Gray - 03 - My Oh My.mp3
I was trying to get rid of the unwanted dashes by replacing them with spaces, and after that deal with all the double and triple spaces.
I hope this explains it better. Thanks for your help. |
|
Back to top |
|
|
admin Site Admin
Joined: 09 Mar 2007 Posts: 448 Location: Canada
|
Posted: Wed May 28, 2008 4:23 pm Post subject: |
|
|
OK. This should do it.
If you want to avoid cutting and pasting every search/replace string below, then you can instead use the mouse to block copy the entire sequence (starting anywhere before 'Row: 1') and then go to the PFrank window, select it, and type ctrl-f2; this will result in the sequence being loaded properly into the top of the custom list.
Row: 1
Search: '[-]{2,9}'
Replace: ' '
Row: 2
Search: '- -'
Replace: ' '
Row: 3
Search: '([^ ])-([^ ])'
Replace: '\1 \2'
Row: 4
Search: '([^ ])-'
Replace: '\1 '
Row: 5
Search: '-([^ ])'
Replace: ' \1'
Row: 6
Search: '_'
Replace: ' '
Row: 7
Search:
Replace: '*Delete All Extra Whitespace in*Prefix*'
The first row takes care of consecutive dashes, the second row takes care of most of the multiple dash sequences that are separated by spaces. Rows 3 to 5 take care of any remaining dash sequences.
Row 6 is used to replace '_' with a space (I assumed that this was required based on your example).
If you have any other questions then let me know.
Peter. |
|
Back to top |
|
|
jaae
Joined: 27 May 2008 Posts: 3
|
Posted: Thu May 29, 2008 12:40 pm Post subject: |
|
|
Thanks Peter, that worked like a charm. Also, an interesting learning experience with regular expressions. |
|
Back to top |
|
|
|