Change many file extension in one folder

Hi there,

I want to change many files in the folder only the extension
For example
111.accdb
112.accdb

to be
111.mdb
112.mdb
how to do this? Thanks for your help

1 Like

Hi,
@delf You can do that by using Movefile activity. Both From path and Destination path would vary only in extension. Attached the XAML for your referenceMain.xaml (9.2 KB)

PFA sample workflow with more dynamic options.
Just change the input directory name, File ext… It will replace all files within directly with new extension

You can restrict the file based on the ext as well just change file ext in “.”

Directory.GetFiles(“C:\Temp Folder\New folder”, “.”)

FileNameRename.xaml (7.6 KB)

1 Like

Hi @pawanbag

works like a charm… Thank you very much.

Best Regards

Delf

1 Like

Hi @rajeev85

Thanks for the reply. It works too but for my case is more suitable using example from @pawanbag

Thanks a lot

Cheers

Delf

@delf Yes, @pawanbag solution looks elegant, mine a sort of rushed in solution :slight_smile:

Hi all,

I want to ask something…
Im encountering an error after i moved to my xaml file for my workflow
Source: Move file

Message: Cannot create a file when that file already exists.

Exception Type: IOException

System.IO.IOException: Cannot create a file when that file already exists.
My workflow is like this
3
4
5

Files_bup path is like this Directory.GetFiles(“D:\LogisticRobot\BUP_DB”, “.accdb”)

is there any wrong with my workflow?

Thanks for your help

Cheers

Delf

Hi @delf,

Directory.GetFiles("D:\LogisticRobot\BUP_DB", "*.accdb")

use * before dot so it will accept any file name contains .accdb files.

Regards,
Arivu

1 Like

Hi @arivu96

Already used this
Directory.GetFiles(“D:\LogisticRobot\BUP_DB”, “*.accdb”)
but still get the error.

Thanks

Hi @delf,

What error are you getting.send screenshot.
Regards,
Arivu

Hi @arivu96

This is the error i get…

Thanks

Regards
Delf

Hi @delf,

This Exception is related to Move File Activity.

If you are moving file to one location to another location make sure the same file should not exists.

Regards,
Arivu

Hi @arivu96

im using @pawanbg sample workflow to just rename the data from .accdb to .mdb
7
and got that error.

Thanks

Regards

Delf

Hi Delf,

Give me some time, working on something urgent, I will look into this issue,

Thanks :slight_smile:

Hi Delf

Thanks, I am happy that solution work for you :smiley::smiley::smiley:

Hi @delf,

i am not sure you can directly change one data type to another data type using Move File activity.

What error are you getting?

Regards,
Arivu

Hi Delf,

I am able to recreate scenario you have described, Actually this is failing as file name after rename is already exists. in order to resolve this issue there are two options

  1. Overwrite the file (just select overwrite property of move file activity
  2. Handle through try-catch or logically, there are multiple ways in this option like moving duplicate file to new location, renaming with different name etc.

PFA revised workflow, Hope this works for you :smiley:Revised

FileNameRename.xaml (8.0 KB)

1 Like

Hi @pawanbag

It works very well. Thanks for your help :smiley:

Regards

Delf

1 Like