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 

Problem building path from filename

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



Joined: 30 Dec 2008
Posts: 3

PostPosted: Tue Dec 30, 2008 4:03 pm    Post subject: Problem building path from filename Reply with quote

Hi,

I am trying to do the following. From a bunch of files like 'test001.jpg', 'test002.jpg, etc' I want to build a directory to store the files. The name of the dir would be the name of the file without extension where the numbers in the file names are replaced by character'#'. So the files would be in the following path:

test###\test001.jpg
test###\test002.jpg
...

I a not sure how to do this in PFrank so if anyone knows how ...

Thank,
Peter.
Back to top
View user's profile Send private message
admin
Site Admin


Joined: 09 Mar 2007
Posts: 448
Location: Canada

PostPosted: Tue Dec 30, 2008 8:02 pm    Post subject: Reply with quote

Here is how to do it.

Copy the following configuration to the first row (do not copy the single quotes):

Row: 1
Search: '(?B)(.*?)([0-9]+)(.*)'
Replace: '\1###/\1\2\3'

The key is the (?B); this is the pathbuilder flag which tells the parser to accept the '/' characters in the replace expression and use them to create folders.

Press scan and check the preview list. If it looks correct then press 'Rename'.

Hope that helps.

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



Joined: 30 Dec 2008
Posts: 3

PostPosted: Wed Dec 31, 2008 10:30 am    Post subject: Reply with quote

This works thanks. But I have forgotten to mention that the number part is not always in the same place. Also there could be more than one number group or no numbers at all. So the idea is to replace any number character with a '#' regardless of its position.

so

01test001.jpg
02test002.jpg
test.jpg

would become

##test####\01test001.jpg
##test####\02test002.jpg
test\test.jpg

So far I have found that

Row: 1
Search: '([0-9])'
Replace: '#'

will replace any number but I don't know how to combine that with the path building flag and the group indicator like '\1'

Would appreciate any help
Back to top
View user's profile Send private message
admin
Site Admin


Joined: 09 Mar 2007
Posts: 448
Location: Canada

PostPosted: Wed Dec 31, 2008 2:47 pm    Post subject: Reply with quote

That's alot trickier but it can be done.

First set the name filter to:

*[0-9]*.jpg


Then insert the following configuration into the specified rows (do not include the single quotes):

Row: 1
Search: '(?E)(.*)'
Replace: '\1.dummy.\1'
Row: 2
Search: '(?x)(\.jpg)$ # delete extensions'
Replace:
Row: 3
Search: '(?E)[0-9]'
Replace: '#'
Row: 4
Search: '(?Bx).dummy. # insert the path separator'
Replace: '/'
Row: 5
Search: '(.*)'
Replace: '\1.jpg'


This time you also need the (?E) extension to isolate the filename prefix plus you have to insert a dummy string which is then later substituted with the path separator.
To save you some time inserting the above row info, you can just block copy this reply with the mouse, go to the pfrank main window and click on it (to select it), then press CTL-F2; that should insert the row info into the custom creator.

Hope that helps!

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



Joined: 30 Dec 2008
Posts: 3

PostPosted: Wed Dec 31, 2008 5:22 pm    Post subject: Reply with quote

Spot on! Amazing!

Thanks,
Peter.
Back to top
View user's profile Send private message
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