Changing extensions with same name in the same file folder

Hello Wonderfull People,
Please I need your help again.
You will find the picture below

I saved an email Excel attachment in a folder and the name of the attachment in a variable . Then, i use an If activity to verify if the attachment extension is (.xls or .csv). If conditions are true, then i want to change the attachment extension to .xlsx. To do that, i am using a excel proces. please look at the picture below.

My problem is:
i want to recuperate the attachment from the folder i save the initial attachment, then save the attachment with .xlsx, all that with the original name , and in the same folder

Any advice would be much appreciated…



1 Like


  1. Once after verifying with if condition whether it is csv or xls file it goes to then block where use a SAVE ATTACHMENT activity and pass the mailmessage variable as input and folder path where u want to save the file
    Repeat the same for all mail messages

  2. Once after saving all the files in that folder now use a Assign activity like this

arr_filepath = Directory.GetFiles(“your folderpath”)

Where arr_filepath is a variable of type array of string

  1. Now use a for each activity and pass this array variable as input
    And change the type argument as string
    Inside the loop use a MOVE FILE activity and pass the source filepath as item.ToString and mention the destination filepath like this


This will change all the valid files and it’s file path with xlsx extension

Cheers @Ricchch

1 Like

Hello @Ricchch

So, After reading all the mails & downloaded the attachment to your Folder. Follow my give steps for changing the Extension of your attachments.

  1. Use an Assign Activity and Assign ArrFilePath= Directory.GetFiles(Attchmentfolderpath). Also, Create a Variable name ArrFilePath which is of type Array of String.
  2. Use “For Each” Activity and pass “ArrFilePath” variable. Also, from the For Each Activity properties panel change argument type to string.
  3. Use Assign Activity inside For Each and Pass lv_Filepath=item.ToString in it.
  4. Use a "Move File activity after Assign and your destination file path should be like this Split(lv_Filepath,”.”)(0).ToString + ”.xlsx”

This will change all .xls and .csv files path with “.xlsx” extension.

Hope this works,
Best Regards.

1 Like

Keep in mind that a fileName renaming is not doing a document format conversion (regardless if Excel pretends to open / display a csv file in the Ui)

For conversion a csv file we can do (one of many options)

  • Read CSV Activity
  • write range Activity

For calculating the new filename we suggest:

As relying on last dot and first part access will fail as we can see here:
The .04 is lost from filename

1 Like

Hello @Palaniyappan and thanks for helping.
i am not sure if i did what you mentionned. you will be able to see what i did in picture below…

i’m using the same path in “save attachment” and “assign” activities.
Thanks for your suggestions,

Hello @ppr and thanks for helping.

Yes, i want to change extension (from .csv or .xls to .xlsx) keeping the same name. So that , my problem is more than renaming.

please advise if you see something i must change here in the picture:

Is the Expression Editor path well adressed? Please consider that my intention for the Attach_name variable was store the name of the attachment in this variable just to use it when i wanted to save it again but with the new extension (.xlsx). What is more, i think that “Save Excel File AS” activity will change automatically the extension …

Thanks for your advise.

@Ricchch Do you got your Solution…If yes then Mark it as Solution.

Hello @pratik.pandya,
Sorry for my late reply, i 'm still working on that.
as soon as finish i will mark solution .

Hello wonderfull People,
Thanks for all your comments. I read it carefully all them and they gave me ideas to rework my workflow. Finally, i found my solution. you’ll see it in picture below

Thanks , much appreciated,


This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.