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.
7 posts Page 1 of 1

kgough

Posts: 7
Joined: Tue Oct 07, 2014 8:35 am

Post by kgough » Tue Oct 07, 2014 8:47 am
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.

Support_Rick

Support Specialist
Posts: 592
Joined: Tue Jul 17, 2012 2:12 pm
Location: Phoenix, AZ

Post by Support_Rick » Tue Oct 07, 2014 3:40 pm
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' ) }
Rick Elliott
Lead Solutions Consultant
(402) 944.4242
(800) 949-4696

kgough

Posts: 7
Joined: Tue Oct 07, 2014 8:35 am

Post by kgough » Tue Oct 07, 2014 3:57 pm
That is exactly what I want.
Should I run the "Set" commands by adding them as "Execute Native Command" steps?

Support_Rick

Support Specialist
Posts: 592
Joined: Tue Jul 17, 2012 2:12 pm
Location: Phoenix, AZ

Post by Support_Rick » Tue Oct 07, 2014 4:11 pm
Not at all .. just use the SetVariable Task

<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

kgough

Posts: 7
Joined: Tue Oct 07, 2014 8:35 am

Post by kgough » Wed Oct 08, 2014 10:25 am
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"

Support_Rick

Support Specialist
Posts: 592
Joined: Tue Jul 17, 2012 2:12 pm
Location: Phoenix, AZ

Post by Support_Rick » Wed Oct 08, 2014 10:39 am
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.
Rick Elliott
Lead Solutions Consultant
(402) 944.4242
(800) 949-4696

kgough

Posts: 7
Joined: Tue Oct 07, 2014 8:35 am

Post by kgough » Wed Oct 08, 2014 1:21 pm
That worked.
Thank you very much!
7 posts Page 1 of 1