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 

Renaming based on a code

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



Joined: 03 Feb 2009
Posts: 5

PostPosted: Wed Feb 04, 2009 12:04 am    Post subject: Renaming based on a code Reply with quote

I've been struggling with this for a while, and it seems possible since this is a powerful tool, but I can not figure it out.

I have a list of several codes i.e. - C01 which is contained in the file name: Inv C01 Remittance Report 2008-12.xls. I want to be able to rename this file to: SAIL 2004-3_SPS_106_C01.xls

These codes are all unique, so i would have to set up a new expression for each one and save them, but it would be worth the time as I would need to rerun these monthly.

Any ideas?
Back to top
View user's profile Send private message
admin
Site Admin


Joined: 09 Mar 2007
Posts: 448
Location: Canada

PostPosted: Wed Feb 04, 2009 3:30 am    Post subject: Reply with quote

Without a larger sampling of old/new filenames, it's difficult to come up with a generic search/replace sequence.
If I assume that the code is surrounded by 'Inv' and 'Remittance' then the following regular expressoin might work for you. Insert the information specified below into the appropriate row/column (do not include the single quotes):

Row: 1
Search: '(Inv.*? )(.*?)( Remitt.*).xls'
Replace: 'SAIL 2004-3_SPS_106_\2.xls'

This expression splits the filename into 3 groups. The code is in the middle group (i.e. group 2).
the replace string then adds the required prefix
(SAIL 2004-3_SPS_106_) to the 2nd group and adds .xls.

If this isn't correct then please provide some additional old/new name pairs with some explanation of how the filenames are formatted so that a general purpose solution can be worked out.

Hope that helps.

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



Joined: 03 Feb 2009
Posts: 5

PostPosted: Wed Feb 04, 2009 5:53 am    Post subject: Reply with quote

Thank you for the quick response.

My problem stems from the form in which I receive these files and the need to standardize the file name. I have thousands of files, all of which have completely different naming conventions. The only constant in these files is the specific code assigned to each file. (Some examples are: 41545, K47, C01, etc.) I would need some sort of expression that will search for just that investor code and match it to my standardized naming convention that I would point to.

My hope for this program was to basically create a mapping for each code that could understand an IF-THEN type of statement. So, IF the file name contained C01 anywhere, THEN it would convert that file name to my specified standardized name - SAIL 2004-3_SPS_106_C01.xls; as in the previous example.

The way I envision it working would be to create these expressions once, which would be time consuming; but they would remain the same month to month.

I hope this makes more sense and I truly appreciate you help.
Back to top
View user's profile Send private message
admin
Site Admin


Joined: 09 Mar 2007
Posts: 448
Location: Canada

PostPosted: Wed Feb 04, 2009 6:19 am    Post subject: Reply with quote

Use the following replace search/replace sequence instead:

Row: 1
Search: '(.*?)(C01)(.*?).xls'
Replace: 'SAIL 2004-3_SPS_106_\2.xls'

When adding additional rows to operate on other codes, just copy row 1 and replace the C01 with whatever code is appropriate.

Cheers,

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



Joined: 03 Feb 2009
Posts: 5

PostPosted: Wed Feb 04, 2009 2:07 pm    Post subject: Reply with quote

This is fantastic and will save me tons of time. Thank you so much for the product and your help.
Back to top
View user's profile Send private message
cauzza



Joined: 03 Feb 2009
Posts: 5

PostPosted: Wed Feb 04, 2009 3:43 pm    Post subject: Reply with quote

One last question. Is it possible to add a standardized date to the end of the new renaming convention that will adjust with the current month?

For example: If the renaming was performed today (Feb 4, 2009) I would want the output to be 02.25.2009. The day of the 25th needs to always be the 25th with only the month and year adjusting based on the current date. Is this possible?

The final renamed file, based on my previous question, would be: SAIL 2004-3_SPS_106_C01_02.25.2009.xls

I set up this date format in the "Date Formatter" but I can not seem to use it in the expression.

Thank you.
Back to top
View user's profile Send private message
cauzza



Joined: 03 Feb 2009
Posts: 5

PostPosted: Fri Feb 06, 2009 10:15 pm    Post subject: Reply with quote

Sorry to bug you again, but do you know if the above post is possible?

Thanks.
Back to top
View user's profile Send private message
admin
Site Admin


Joined: 09 Mar 2007
Posts: 448
Location: Canada

PostPosted: Sat Feb 07, 2009 4:14 am    Post subject: Reply with quote

Yes it is possible.

Add the following row to the end of your custom renaming sequence (do not include the single quotes):

Search:
Replace: '*Insert File Properties after*Prefix*'

This is the same as using the 'Insert in list' from the pre-defined commands panel after you've chosen the 'insert file properties after' and the 'prefix' option.

Before pressing scan do the folloiwng:
1)
go the options window, from the left-hand side select 'date formatter' and from there select custom, and then choose the code for displaying the month format e.g. %b
2)
from the left-hand side, select 'file properties insertion' and from there select %CurrentDate% in the custom format line.

Now press scan on the main window.

Hope that helps.

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 -> 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