Name file change method

studio
variable

#1

How can I change the name of a file by assign method?

name


#2

Try with the Invoke Code activity and call System.IO.File.Move method to rename the file.

System.IO.File.Move(“origFileName.txt”, “newFileName.txt”)

You can’t use the System.IO.File.Move method in an Assign activity because this method does not return a value and the assign operation requires an expression that can be evaluated and then assigned to a variable.


#3

Yes, but I want to change a name file, don´t knowing is name, Just saving the new name on a variable, and then change the name for various files, for example: file_1,file_2,file_3 …


#4

HI @fabiosantos_99,

use copy File activity to copy the file from one folder and paste it into another folder there you can change the file name.

image

Destination you can change the path and file name
"D:\Filename_1.xlsx"

Refer this

Regards,
Arivu


#5

Thanks for your quick reply,

I´m already using the save mail activity, doesn´t have a activity to move and to be possible change names to??
And I don´t even know the name file, so I think I can´t copy it without knowing is name…


#6

Are you using Save Mail Message activity and then you want to rename the file? Then you can use the new name directly for FilePath property.

Or are you saving the email attachments using the Save Attachments activity? In this case you can get the file names using the Attachment.Name property.
For example, the name of first attachment in the first email of your collection would be

myEmails(0).Attachments(0).Name


#7

Thanks for the quick reply,

Yes, I saving attachments, but not just 1 or 2, I want to create diferent names for diferent mail attachments, and then would be more easy to do the rest of the program.


#8

thanks, it helped.