Renaming files through variable

Hi all,
I have attached the recording (1.1 KB) where i rename the file using the variable after moving it to a new folder.As, renaming option is not readily available i have used keyboard shortcuts to do it. But, i’m not able to rename the files. Kindly share suggestions to make it work.

1 Like

Hi Arthi,

I would suggest renaming a file via Command prompt.

  • save the path to the file and the new name in variables
  • open Command prompt using Win + R
  • execute command: rename ${filepath} ${new_name}

Don’t forget to switch to Run and Command prompt windows using the Window action before typing anything in these windows.

Here is a short sample recording (758 Bytes)

Let me know if it helps!

1 Like

@Arthi did you have a chance to try the sample, did it work?

Greetings!.I was not around will check and intimate you.

I executed the above code and it works great!! thank you :slight_smile::blush:

1 Like

Hi, this works for a single file , what if you have a list of file paths on an excel sheet(Column A, and column B has the new name) is it possible to rename using a for-loop?

1 Like

@trisha it looks doable. Try reading both columns in2 List variables and put the actions to rename the files in the For Each loop to iterate through the first list.

To iterate through the second list, use an index that you will increment by 1 at the end of the loop.

Hi @ashapkina , I just wanted to ask if you plan to add this feature (file name change). The solution with cmd is not working for me. I can write an excel macro for that but I’d prefer to do it with the bot.

Another way is to use custom script


@CustomScriptAction(  input = ['from_file', 'to_file'] )

def customScript() {  
def original_file = new File(from_file.toString())
def new_file = new File(to_file.toString())

This would also be useful as part of the Copy File/Folder action. Allow supplying a folder path and filename for the destination.