I have a requirement to rename a file based on previous file name.
Is it possible?
For example
xx2014-10-07TEST.txt
will be renamed
xx07-10-2014tst.txt
I cannot use the current date function because I may have to process older files.
Rearrange file name
Post any question you may have in regards to GoAnywhere Director and let our talented support staff and other users assist you.
- Support_Rick Offline
- Support Specialist
- Posts: 590
- Joined: Tue Jul 17, 2012 2:12 pm
- Location: Phoenix, AZ
- Contact:
Re: Rearrange file name
kgough,
You're option here is to parse the original file name. Something like:
Set FYear = Substring( FName, 3, 4 )
Set FDay = Substring( FName, 8, 2 )
Set FMonth = Substring( FName, 11, 2 )
Then, create your new file name:
Set NewFile = ${ Concat( 'xx', FMonth, '-', FDay, '-', FYear, 'tst.txt' ) }
You're option here is to parse the original file name. Something like:
Set FYear = Substring( FName, 3, 4 )
Set FDay = Substring( FName, 8, 2 )
Set FMonth = Substring( FName, 11, 2 )
Then, create your new file name:
Set NewFile = ${ Concat( 'xx', FMonth, '-', FDay, '-', FYear, 'tst.txt' ) }
Rick Elliott
Lead Solutions Consultant
(402) 944.4242
(800) 949-4696
Lead Solutions Consultant
(402) 944.4242
(800) 949-4696
Re: Rearrange file name
That is exactly what I want.
Should I run the "Set" commands by adding them as "Execute Native Command" steps?
Should I run the "Set" commands by adding them as "Execute Native Command" steps?
- Support_Rick Offline
- Support Specialist
- Posts: 590
- Joined: Tue Jul 17, 2012 2:12 pm
- Location: Phoenix, AZ
- Contact:
Re: Rearrange file name
Not at all .. just use the SetVariable Task
<setVariable label="set FDay" name="FDay" value="${Substring( FName, 8, 2 )}" version="2.0" />
<setVariable label="set FDay" name="FDay" value="${Substring( FName, 8, 2 )}" version="2.0" />
Rick Elliott
Lead Solutions Consultant
(402) 944.4242
(800) 949-4696
Lead Solutions Consultant
(402) 944.4242
(800) 949-4696
Re: Rearrange file name
When I try that I get an error:
<setVariable label="Set JJ-Day" name="JJ" value="${Substring( LocalFile, 24, 2 )}" version="2.0" />
Variable not found: Substring( LocalFile, 24, 2 )
My main project is Version 1, is that the problem?
Then if I switch to V2 I get an error in my ExecuteOnlyIf
executeOnlyIf="${myLocalFileCount} ge 1"
<setVariable label="Set JJ-Day" name="JJ" value="${Substring( LocalFile, 24, 2 )}" version="2.0" />
Variable not found: Substring( LocalFile, 24, 2 )
My main project is Version 1, is that the problem?
Then if I switch to V2 I get an error in my ExecuteOnlyIf
executeOnlyIf="${myLocalFileCount} ge 1"
- Support_Rick Offline
- Support Specialist
- Posts: 590
- Joined: Tue Jul 17, 2012 2:12 pm
- Location: Phoenix, AZ
- Contact:
Re: Rearrange file name
Ken,
Upgrading to version 2 will get you a bit more functionality with your Expression Wizard.
When editing the Version 1 project, click on the Upgrade button and convert to Version 2. Then, your Expression Wizard will give you the options you need for the Functions (Substring, Contains, etc)
Don't forget that the syntax of the command changes with this.
${var} eq 'x'
now becomes...
${ var eq 'x' }
Let us know if you have any other questions.
Upgrading to version 2 will get you a bit more functionality with your Expression Wizard.
When editing the Version 1 project, click on the Upgrade button and convert to Version 2. Then, your Expression Wizard will give you the options you need for the Functions (Substring, Contains, etc)
Don't forget that the syntax of the command changes with this.
${var} eq 'x'
now becomes...
${ var eq 'x' }
Let us know if you have any other questions.
Rick Elliott
Lead Solutions Consultant
(402) 944.4242
(800) 949-4696
Lead Solutions Consultant
(402) 944.4242
(800) 949-4696
Re: Rearrange file name
That worked.
Thank you very much!
Thank you very much!