Rename file after save file attachment

I want to rename file after save file attachment from outlook in my com.
Example : file name Abby report.txt

I want to add text AEC before original name (AEC Abby report.txt)

Please guide me about it.

1 Like

Hi

Once after saving the attachment using save attachment activity we can use MOVE FILE activity to rename the file where in source mention the filepath of the file where it is saved
And
In destination part mention like this

“Folder path”+”\”+”AEC “+Path.GetFilenamewithoutextension(“Filepath”)+Path.GetExtension(“filepath”)

Cheers @fairymemay

@Palaniyappan How to get file path?

image

Because I save file in D:\RPA and It have many files.

I want to rename latest file.

1 Like

Fine

Hope the below steps would help you resolve this

  1. As the attachments are now saved in “D:\RPA\”
    Then use a assign activity like this

str_filepath = Directory.GetFiles(yourfolder_path,"*.txt").OrderByDescending(Function(d) New FileInfo(d).CreationTime).Tolist(0)

Where str_filepath is a string variable

  1. Now use a Move file activity where in source mention as str_filepath and in destination mention as

“D:\RPA\”+”AEC_”+Path.GetFileNameWithoutExtension(str_filepath)+Path.GetExtension(str_filepath)

Hope this would help you

Cheers @fairymemay

Were we able to change the file name @fairymemay

1 Like

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