How to change the all excel file names in a folder

hello

I am trying to change all the excel file names in a folder. Can anyone help me?

I have retrieved all the excel file names in the folder in an Array. But now i am confused.

Eg: File name is “ABC PVT LTD_BS.xlsx”. Now i just want to replace the “_BS” with “”.

P.S. All files contain “_BS”.

Thanks in advance. @ALL

1 Like

Fine
you were almost done @AryanSingh
–once gettting with array use for each loop and pass the array variable to that and change the type argument as string
–then inside the loop use a if condition and mention like
item.tostring.contains(“BS_”)
If true will go to THEN part where use a add to collection activity like this
–in collections property mention like out_list_filepath
–and in item property mention like this
item.ToString.Replace(“BS_”,"")
and change type argument to string

where out_list_filepath is a variable of type list(of string) with default value like
New list(of string) defined in the variable panel

–now we can use this out_list_filepath as a collection of filenames and we can pass that to a for each loop and make use of if where we want

simple isnt it
Cheers @AryanSingh

1 Like

Try itChange File Name.zip (16.9 KB)

1 Like

Movefile.xaml (6.2 KB)

Try this

1 Like

Thank you. I will try and get back to you

Thanks

@Palaniyappan
@srdjan.suc
@huhuhug

2 Likes

Great
Cheers @AryanSingh

1 Like

@Palaniyappan
I tried ur method, i am not able to replace the name in the destination folder.

@Palaniyappan

Please check the screenshot provided.

1 Like

It should actually work
May I know what Output we expect buddy
As this would actually replace the .CSV extension at the last of file name with null value like this
Filename.CSV to Filename
Cheers @AryanSingh

@Palaniyappan

actually i got the sheets like this in result with name like aryan.CSV.xlsx.

So, extension is “.xlsx”. That’s why in want to remove the .CSV from the file name and keep the file name aryan.xlsx.

All files have this “.CSV” string.

This looks good actually
And I wonder why it didn’t
Can I have a view in the xaml if possible
Kindly share the xaml with project.json file all zipped together and let’s fix it buddy

Cheers @AryanSingh

@Palaniyappan

Sorry bro, i am not able to send the xaml.

Please check the image.

If need any specific information please tell me!

1 Like

fine
No worries
Let’s debug
—inside the THEN part use a writeline activity and mention like “Entered THEN”
Before tk the add to collections activity

I would like to check whether it’s entering the THEN PART
And also in the ELSE part use a writeline activity and mention like file.ToString

Make sure that the type argument of for each loop in the property panel is with String type

Kindly share the screenshot of output panel and let’s check whether it has entered the THEN part or not

Cheers @AryanSingh

1 Like

@Palaniyappan

able to enter the then part of the if activity. Please check the screenshot.

1 Like

Fantastic
i guess we miss something with items property in the add to collections
no worriies
–lets use a assign activity inside the THEN part before add to collections with a variable oftype string named out_filename
out_filename = file.ToString.Replace(".CSV","").ToString
–now use a writeline activity next to this assign activity like this
out_filename.ToString //this is to check whether the .CSV got replaced with null or not

–now lets use a add collections with collections property mentioned as out_list_filepath and item property as out_filename.ToString and Type argument as string

Kindly share the screenshot of the output panel after this run buddy

Cheers @AryanSingh

1 Like

Great
We were able to get now @AryanSingh

@Palaniyappan

ok let me try. Thanks

1 Like

@Palaniyappan

In the workflow it is showing that it has changed but not changing at the destination(Folder). Do i need to do any other steps for it to change the file name in the folder also!

1 Like

Aaha
So you want that to get rejected in the folder path as well right
So next to add to collection use a move file activity where in the source mention as file.Tostring and in the destination mention as out_filename.ToString (which is the variable that we have from assign activity)

That’s all you are done
Cheers @AryanSingh

1 Like

@Palaniyappan

Let me try an get back to u.Thanks

1 Like