Copying & Renaming file problem

Hey guys,
I faced the problem with copying and renaming file.
Flow:
-Robot receives multiple emails with multiple invoices.
-downloads attachments
-renames files and sends them into folders

The problem is that while copying and renaming i receive Error: The given path’s format is not supported…
80% all works fine, but with specific email and it’s attachments error is occured.

Currently recieve error with file name: ארוחות מכתשים איירפורט 9.19 108033
to be copied with name: 1:08033-y#עידית לוגיסטיקת מזון#.pdf
Any ideas what going on here?
Thanks

Hi Slavich,

In the File name some special characters will not allow.

“:” - this is not allowed, so try replacing this with other character and try.

Hope this might helps you

Thanks

1 Like

@ksrinu070184,
But when I do renaming with “:” with hands - it allows…

use string operations

like Yourstring.replace(":", “-”)

Thanks

@ksrinu070184,
What about
Copy and rename from :
c:\Invoices_from_email\IC19108789.pdf
to:
c:\Invoices_from_email\IC19108789-r-y_MSC_.pdf

The same Error…

This looks good, are you getting exception with this? What exception you are getting? Try by copying to a different folder instead of trying within the same folder.

@sarathi125,
I recieve
Error: Illegal characters in path…
even when I copy to other folder.

Hi @Slavich

A couple of things I like to do is

  • Make sure that the path + filename length doesn’t exceed the default windows max

yourFilename.count > 260

  • Strip any invalid windowns characters

validFilename = regex.replace(yourFilename, path.GetInvalidFileNameChars(), “-”)

or whatever you want to replace with.

1 Like