Peters Flexible RenAmiNg Kit (PFrank) Forum Index Peters Flexible RenAmiNg Kit (PFrank)
Support and Discussion Site for the PFrank File/Folder Renaming Tool (***NEW HOME PAGE*** "http://pfrank.atwebpages.com")
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Replacing occurrence of Characters nr. X

 
Post new topic   Reply to topic    Peters Flexible RenAmiNg Kit (PFrank) Forum Index -> General Support
View previous topic :: View next topic  
Author Message
t-buch



Joined: 27 Aug 2007
Posts: 9
Location: Denmark

PostPosted: Mon Feb 06, 2012 1:45 pm    Post subject: Replacing occurrence of Characters nr. X Reply with quote

Sample text:
Baroque Masterpieces - A. Marcello - Oboe Concerto in D Minor - Adagio (02).wav
Replaced Text:
Baroque Masterpieces - A. Marcello - Oboe Concerto in D Minor, Adagio (02).wav

So here I want to replace the occurrence nr. 3 of the character " - " with ", ".
The two first occurrence of the character " - " I want to keep
_________________
Thomas Buch
Back to top
View user's profile Send private message
admin
Site Admin


Joined: 09 Mar 2007
Posts: 448
Location: Canada

PostPosted: Wed Feb 08, 2012 7:40 am    Post subject: Reply with quote

Try using the following in the custom renaming creator (do not include the single quotes).

Row: 1
Search: '^(.*?)(-)(.*?)(-)(.*?)(-)(.*)'
Replace: '\1\2\3\4\5, \7'


The filename search finds 7 groups and the new name replaces the 6th group (which is a dash), with a comma.
You can use subsequent rows to clean up the whitespace.

Hope that helps.

Peter.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
t-buch



Joined: 27 Aug 2007
Posts: 9
Location: Denmark

PostPosted: Wed Feb 08, 2012 7:59 pm    Post subject: Reply with quote

Thanks, Peter

Is there a shorter regex if you could go from right to left?

I notice you are using "^" - what if you are using "$"??

----

By the way - I found my own solution before you send me your answer
This was a "two Rows solution":

Row: 1
Search: "(.*-)" Replace: "\1¤"

Row 2
Search: " -¤" Replace: ","
_________________
Thomas Buch
Back to top
View user's profile Send private message
admin
Site Admin


Joined: 09 Mar 2007
Posts: 448
Location: Canada

PostPosted: Wed Feb 08, 2012 9:22 pm    Post subject: Reply with quote

Yes you are correct in that you could use a much shorter expression that wouldn't depend on the number of dashes in the name. You just have to the non-greedy specifier (as you did with your solution).

something like:
search for '^(.*)-(.*)$' and replace with '\1, \2'

I think that will do the same as yours but in one row instead of 2.

Peter
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Peters Flexible RenAmiNg Kit (PFrank) Forum Index -> General Support All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © phpBB Group. Hosted by phpBB.BizHat.com


Start Your Own Video Sharing Site

Free Web Hosting | Free Forum Hosting | FlashWebHost.com | Image Hosting | Photo Gallery | FreeMarriage.com

Powered by PhpBBweb.com, setup your forum now!
For Support, visit Forums.BizHat.com