Peters Flexible RenAmiNg Kit (PFrank) Forum Index Peters Flexible RenAmiNg Kit (PFrank)
Support and Discussion Site for the PFrank File/Folder Renaming Tool (http://www3.telus.net/pfrank)
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Moving a String within a file plus replacing underscores

 
Post new topic   Reply to topic    Peters Flexible RenAmiNg Kit (PFrank) Forum Index -> Regular Expressions
View previous topic :: View next topic  
Author Message
mnemon



Joined: 04 Oct 2011
Posts: 3

PostPosted: Tue Oct 04, 2011 8:10 pm    Post subject: Moving a String within a file plus replacing underscores Reply with quote

Hi,
appologies in advance, I am not good enough in regex to cobble together the expression I am looking for from the examples already posted in this forum.

I am trying to rename a couple of files:
053191516x_soandso_press_analysis_of_criminal_evidence_jul_2005.pdf to

analysis_of_criminal_evidence-soandso_press-053191516-jul_2005.pdf

so the logic of the result is <title>-<publisher>-<isbn>-<date>.pdf

With '(^\d{6})(.*)-(.*)' i can grab the numbers, but I dont know how to identify the `_` to replace by `-`.

Any help gratefully accepted.
Back to top
View user's profile Send private message Send e-mail
admin
Site Admin


Joined: 09 Mar 2007
Posts: 446
Location: Canada

PostPosted: Wed Oct 05, 2011 6:36 pm    Post subject: Reply with quote

Try putting this in the renaming creator (do not include the single quotes):

Row: 1
Search: '(?E)^(\d*)(.*?)(.{3,3}_\d{4,4})'
Replace: '\2-\1-\3'
Row: 2
Search: '_'
Replace: '-'

This will take care of the isbn and the date.
But you need to find some way to spepcify how the title and publisher are separated and use the information to split the title/publisherinto 2 groups which can then be swapped.

Hope that helps.

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



Joined: 04 Oct 2011
Posts: 3

PostPosted: Wed Oct 05, 2011 10:11 pm    Post subject: Thanks! Reply with quote

Thank you so much for the quick reply. The preview already looks awesome, but you are right, I need to identify the publisher, otherwise ALL "-"s will be replaces, wich looks weird.

The easiest way of identifying the publisher is probably by name, since most of the files have the same publisher.

The second possiblity would be "from the first underscore" to the string "press".

Any ideas how that might look like?
Back to top
View user's profile Send private message Send e-mail
admin
Site Admin


Joined: 09 Mar 2007
Posts: 446
Location: Canada

PostPosted: Thu Oct 06, 2011 6:58 am    Post subject: Reply with quote

You could add another group into row 1:

Row: 1
Search: '(?E)^(\d*)(.*?press)(.*?)(.{3,3}_\d{4,4})'
Replace: '\3-\2-\1-\4'
Row: 2
Search: '_'
Replace: '-'
Row: 3
Search: '^\-'


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



Joined: 04 Oct 2011
Posts: 3

PostPosted: Sat Oct 08, 2011 9:58 pm    Post subject: Thanks! Reply with quote

Worked like a charm, the understores at the files beginning where easy to remove.
Thank you again for your help and the great work you did with that tool! You should have gotten mail Smile
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    Peters Flexible RenAmiNg Kit (PFrank) Forum Index -> Regular Expressions 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