View previous topic :: View next topic |
Author |
Message |
pkoender
Joined: 30 Dec 2008 Posts: 3
|
Posted: Tue Dec 30, 2008 4:03 pm Post subject: Problem building path from filename |
|
|
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 |
|
|
admin Site Admin
Joined: 09 Mar 2007 Posts: 448 Location: Canada
|
Posted: Tue Dec 30, 2008 8:02 pm Post subject: |
|
|
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 |
|
|
pkoender
Joined: 30 Dec 2008 Posts: 3
|
Posted: Wed Dec 31, 2008 10:30 am Post subject: |
|
|
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 |
|
|
admin Site Admin
Joined: 09 Mar 2007 Posts: 448 Location: Canada
|
Posted: Wed Dec 31, 2008 2:47 pm Post subject: |
|
|
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 |
|
|
pkoender
Joined: 30 Dec 2008 Posts: 3
|
Posted: Wed Dec 31, 2008 5:22 pm Post subject: |
|
|
Spot on! Amazing!
Thanks,
Peter. |
|
Back to top |
|
|
|