Change many file extension in one folder


#1

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


#2

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)


#3

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)


#4

Hi @pawanbag

works like a charm… Thank you very much.

Best Regards

Delf


#5

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


#6

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


#7

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


#8

Hi @delf,

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

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

Regards,
Arivu


#9

Hi @arivu96

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

Thanks


#10

Hi @delf,

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


#11

Hi @arivu96

This is the error i get…

Thanks

Regards
Delf


#12

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


#13

Hi @arivu96

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

Thanks

Regards

Delf


#14

Hi Delf,

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

Thanks :slight_smile:


#15

Hi Delf

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


#16

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


#17

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)


How to move a directory and its files to a new path
#18

Hi @pawanbag

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

Regards

Delf