Groovy script syntax for concatenating string

I would like to rename a file from ${path1}${file1} to ${path2}${file2} but unsure of the Groovy syntax for concatenating string in the script,

How should the lines below be written?

import java.io.File;

@CustomScriptAction(
        input = ['path1', 'path2','file2','file2']
    )
 
def customScript() {
  
def original_file = new File (path1.toString+'\'+file1.toString()) ??
def new_file      = new File (path2.toString+'\'+file2.toString()) ?? 

original_file.renameTo(new_file);
}

@gancw you don’t need to concatenate strings in the custom action. There is an action Join Strings in the Actions Library that does it. Or you can combine 2 strings using Constant Value action.

@ashapkina, I know I can combine the string outside of the script but I want to avoid unnecessary temporary variables

1 Like

Got it.

You need to adjust the script a bit:

import java.io.File;

@CustomScriptAction(
        input = ['path1', 'path2','file1','file2']
    )
 
def customScript() {
  
def original_file = new File ((path1 +'\\'+file1).toString())
def new_file      = new File ((path2 +'\\'+file2).toString()) 

original_file.renameTo(new_file);
}