How to fix the creating file error

I kept getting this error “Rename File: Cannot create a file when that file already exists.” when there is not existing file, im not sure which part is wrong.

Cheers

Hi @superpunchypp

I think the File doesn’t exist in the provided folder. If there is no file then the rename file activity will throw this error.

First check the file exist or not by File Exist activity, If file exist it rename the file.

Check the below workflow here

Hope it helps!!

@superpunchypp

you can also try in this way

how to override the cannot create because got similar rename as i want to keep both the new renamed docx even though both have same renamed name

how to override the cannot create because got similar rename as i want to keep both the new renamed docx even though both have same renamed name.

Here we can copy the same file and rename it by using Copy file activity.

In the From field give the Path of the File to be copy and rename. In the To field give the Path of the same but change the name of the file.

Check the below workflow for better understanding.

Hope you understand!!

My issue is before renaming is different name but both rename will be the same after renaming, E.g. “File-A1” and “File-A2”, and in this case A1 and A2 has the same name but I want to still keep both file after renaming it even if both have same name but in the file is different.

Okay @superpunchypp

I got your point, This will not happen because the system will not accept of changing the other file with the same name. If you do it manually you can do it as the UiPath also throws error.

It will throws this error we can’t do it in the same paths but we can make it by giving the another path.
image

Hope you understand!!

Hi @superpunchypp ,
If you want both the file before and after rename having same filenames, then you could try out the below steps if your business allows:

  • Create two folders “Original” and “Rename”
    *Place the files in the respective folder thereby having both files having same names but diff content.

Hope this helps.

Regards,

Hello,

For this error, most of the time a file may be corrupted even if it is not showing in that folder, so the best way is to delete that folder and create a new folder with the same name.

Also, make sure to check if there are any hidden files.

To check hidden files in a folder:

  • Open File Explorer from the taskbar.
  • Select View > Options. Change folders and search options.
  • Select the Viewtab and, in Advanced settings, select Show hidden files, folders, and drives, and OK.

I hope this will help to resolve the issue.

Ok, i understand, so how do i replace the existing file name or file with same name so the my process contiune runs without this error, im using rename file activity

Ok, i understand, so how do i replace the existing file name or file with same name so the my process contiune runs without this error, im using rename file activity.

Ok, i understand, so how do i replace the existing file name or file with same name so the my process contiune runs without this error, im using rename file activity

@superpunchypp …Move the old file with same name to Old/Original folder and then place the new (Overwrite ) renamed file in the required path as you have already moved the old one.

Hey,

  1. In Copy File activity, set the From property to the file you want to save.
  2. In Copy File activity, set the To property to the same path as the source file.
  3. Just make sure that the Overwrite property option is checked.

Or you can use the Move File activity to move the file to the same location with the same name.

Please refer below steps:

  1. In Move File activity, set the Source property to the file you want to move.
  2. In Move File activity, set the Destination property to the same path as the source file.
  3. Make sure that the Overwrite property option is checked.

I hope this helps!

Hi @superpunchypp ,
file or path exists, we can rename with exist name, we can check before renaming.
if exists, we can have options, create new name.
or we can delete the old file, we can delete the file and then rename it.
This depends on our decision before wanting to change
‘file exist’ or ‘path exist’ can useful in this case

regards,

do you have UiPath example file?

Cheers

is it possible to keep key to the back of the new renamed file, E.g. File - John A1 instead of File - John for the file that has same name cause some like A2 might be also John so i need to have both but A1 or A2 at the back to differentiate it.

Yes, you can, name the file based on your requirements, create the name as you want before changing
Cheer @superpunchypp

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