Rename File: Could not find a part of the path

I’m using a for each file in folder and renaming each file using rename file, it was working before but out of nowhere it started generating the error “Rename File: Could not find a part of the path.”

Hi @gustavo.souza

You need to pass the full path instead of file name
Pass: CurrentFile.ToString

1 Like

@gustavo.souza
Use current file.tostring instead of currentfile.name

Or
Try with the extension currentfile.name.tostring

Hope it helps!!

1 Like

None of the alternatives worked, I also tried to create a variable with the path and test it this way, but it didn’t work, it doesn’t rename

@gustavo.souza
Check the path using message box whether passing correct or not
Hope it helps!!

Hi @gustavo.souza

Can you check if you are giving the correct full path of the file?
Also you can check whether the variables passing the correct full path of the file?

Thanks,
Srini

CurrentFile.FullName is the path and filename. You should get in the habit of using the properties.

He is using CurrentFile.FullName which is the correct property

Put a breakpoint on Rename File, run in debug mode, when it pauses check the panel on the left to see the value of CurrentFile.FullName

@Parvathy @Srini84
I checked and it really is coming with the correct name

@gustavo.souza

You mean you are getting only the fileName? Can you try passing the entire full path of the file and try?

Thanks,
Srini

But here, it’s asking the path of the file.
image

@gustavo.souza

You need to give entire filepath

Hope this may help you

Thanks,
Srini

@gustavo.souza

Check below link for your reference

https://docs.uipath.com/activities/other/latest/workflow/rename-file-x

Thanks,
Srini

CurrentFile.FullName is the full path and filename.

CurrentFile.Name is just the filename.

1 Like

Oh ok I understand. Thanks for sharing knowledge.

@gustavo.souza

This below syntax must be passed in the file field

CurrentFile.ToString

and please do check the data that being stored in the variables passed in the New Name field.

Hope it Helps!!

No. CurrentFile.FullName is the full path and filename. CurrentFile.Name is just the filename.

@postwick @supriya117 @Srini84 @pravallikapaluri
Guys, I am receiving the correct name of the file in the Message Box, however, it does not rename, before it was renaming normally and the error did not happen.

I’m using CurrentFile.FullName, and I’ve already tested the option mentioned by everyone, but I still get the error.

Captura de tela 2023-07-20 112316

Is the file read-only? Does someone have the file open?