# How to copy excel file and change the file name?

Hello,

1. If there is no current date file, copy last month file.
2. Change the file name to yyyy-MM(This month)
3. Save

Directory.GetFiles(“D:\Users\01048398\Desktop\Treasury_CashReport_Final”,""+Today.ToString(“yyyy-MM”)+".xlsx")

You can use a copy file/move file activity and your desired file name. Don’t forget to include the file extension.

@kenneth.m Thank you for your comment.
I’ve tried to rename the target file with Move File activity but faced below error message.
which script should I change ?

Hello~
Could you please review which part is wrong?
FileSystem.Rename(“D:\Users\01048398\Desktop\Treasury_CashReport_Final\template”,“D:\Users\01048398\Desktop\Treasury_CashReport_Final\Today.ToString(“yyyy-MM”)”)

Please mention the file name in existing path details. I have attached screenshot for your reference.

Happy Learning

It should be coded like this. FileSystem.Rename(“D:\Users\01048398\Desktop\Treasury_CashReport_Final\template”,“D:\Users\01048398\Desktop\Treasury_CashReport_Final\" + now.ToString("yyyy-MM"))

You can see no error in the invoke code

FileSystem.Rename(“C:\Users\giris\Desktop\text.txt”,“C:\Users\giris\Desktop\text-" + now.ToString("yyyy-MM") + ".txt")