View previous topic :: View next topic |
Author |
Message |
cauzza
Joined: 03 Feb 2009 Posts: 5
|
Posted: Wed Feb 04, 2009 12:04 am Post subject: Renaming based on a code |
|
|
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 |
|
|
admin Site Admin
Joined: 09 Mar 2007 Posts: 448 Location: Canada
|
Posted: Wed Feb 04, 2009 3:30 am Post subject: |
|
|
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 |
|
|
cauzza
Joined: 03 Feb 2009 Posts: 5
|
Posted: Wed Feb 04, 2009 5:53 am Post subject: |
|
|
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 |
|
|
admin Site Admin
Joined: 09 Mar 2007 Posts: 448 Location: Canada
|
Posted: Wed Feb 04, 2009 6:19 am Post subject: |
|
|
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 |
|
|
cauzza
Joined: 03 Feb 2009 Posts: 5
|
Posted: Wed Feb 04, 2009 2:07 pm Post subject: |
|
|
This is fantastic and will save me tons of time. Thank you so much for the product and your help. |
|
Back to top |
|
|
cauzza
Joined: 03 Feb 2009 Posts: 5
|
Posted: Wed Feb 04, 2009 3:43 pm Post subject: |
|
|
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 |
|
|
cauzza
Joined: 03 Feb 2009 Posts: 5
|
Posted: Fri Feb 06, 2009 10:15 pm Post subject: |
|
|
Sorry to bug you again, but do you know if the above post is possible?
Thanks. |
|
Back to top |
|
|
admin Site Admin
Joined: 09 Mar 2007 Posts: 448 Location: Canada
|
Posted: Sat Feb 07, 2009 4:14 am Post subject: |
|
|
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 |
|
|
|