How to rename file to dynamic names

Hello people, I am new to uipath studioX and I would like to rename the files dynamically like “file_v01_yyyymmdd.xlsx”, “file_v02_yyyymmdd.xlsx” and etc. Currently, when I rename the file name it will give an error saying “it cannot create the file that is already exist although the date in the filename is different”. I saw a solution on this problem in studio and I try to apply in using the text function in studioX but it’s not working as it intended. Hence, I would like to seek some help here.

Thank you in advance !

Try “file_v02_”+datetime.now.toString(“yyyyMMdd”)+“.xlsx”

Hi @winne.oo

Welcome to Community,

First you need to get your file name from the path.

then You can use “YourPath”+“YourFileName” +datetime.now.tostring(“yourdesiredformat”) +“.xlsx”

Thanks.

@sb001 and @suraj.setty thank you so much for the response. But I want the v01 and v02 to change dynamically like a version to indicate which file is the latest downloaded one.

1 Like

I tried both of your solution @sb001 and @suraj.setty but it did not work. I get error message saying “Illegal characters in path”.

Hi @winne.oo

If you want to know the latest file that has been downloaded you can use the

“YourPath”+“YourFileName” +datetime.now.tostring(dd_MM) +“.xlsx”

Which will include the complete timestamp , so each file will have the unique timestamp attached to it ,try this

datetime.now.ToString(“dd_MM_yyyy_hh_mm_ss”)

Thanks.

Hi @suraj.setty
The file is actually a newly downloaded attachment from email. Then I would like to change the filename to a readable one and also to distinguish the newly downloaded file. I used the notebook in studioX to reformat the filename like this “filename_yyyymmdd.xlsx”. Every month I will download the file and whenever it runs it will overwrite the previously downloaded file although the datetime is different. If I unchecked the overwrite option, it will prompt an error saying the file already exist. Do you have a solution for this problem ?

before write the file check the file is already existing with same name

Can you please share screenshot of this error and the file name you have tried?

@winne.oo
Add Time Stamp to your File like
Try “file_v02_”+datetime.now.toString(“yyyyMMdd_hhmmss”)+“.xlsx”

So, it will uniquely identify file name Every time it Downloaded.

Image 1 - Error message

Image 2 - I tried the solution you suggest and I get the error message show in image 1
image

Please guide me on this I’m not sure what or where went wrong.

So you want to rename file while Downloading it from email Right? (Using Studiox)

Can you share screenshot of your code?

Hi @sb001, yes I want to rename file while downloading it from email.
Sorry I can’t share screenshot of my code due to certain policy.
However, I have outline my code as shown below. If you are unclear about anything feel free to ask me.
This project is fully implemented using studiox.

Thank you.

Can you use rename file activity instead of move file and try Once.

I can’t find rename file activity in my studioX.

I can see that in my StudioX.

I can’t find it in my studioX. I only have rename excel sheet. My friend have it too but I can’t find it in my studioX. I have already uninstalled my studioX and reinstalled again yesterday but I still couldn’t find rename activity in my studioX.

image

com
u can see rename file activity by enabling classic filter
as shown in figure above

image

As shown in the figure, I don’t have ‘Show Classic’ option in the filter.

Can you Check once by upgrading uipath.system.activities and uipath.excel.activities Package versions.