File rename and formate change

Hi Guys,
I want create a flow for below things.
In a particular folder lot of files will be stored. I want to select the recently added files(.XLS) then open that file and change the file formats from .XLS to .XLSX and rename the file name for current date and time.
Can some one help me on this. And give some examples
Thanks

@vivek_sivam

In the above case all he can do is the following:-

  1. Open (.xls) file.
  2. Use shortcut keys to get to the “Save as” file window
  3. Type the file path along with the file name.

Note:- When we use the shortcut keys to reach the “Save As” window, you can naturally see the “file type” to be [Excel] Workbook , which means (.xlsx) file.

To give the string name, you can use the date time stamp to save with unique name.

Best Regards,
@hacky

Hi @hacky
Thanks. I want run this flow for daily. Can you please give some examples or flows.
How to create a flow

@vivek_sivam

If you are asking about Step 2, shortcut keys, you can simply try to use these shortcut keys manually and note them down.

In my system, following sequence works best, note below images for reference:-

  1. Step 1 -> When the excel is open, to go to files (sendhotkey (ALT + F))

  2. Step 2 -> to export, (sendhotkey (ALT + E))

  3. Step 3 -> to Change file type, (sendhotkey (ALT + C))

  4. Step 4 -> to go to Workbook option, (sendhotkey (ALT + Q))

  5. Step 5 -> to click on the Workbook option, (sendhotkey (enter))

This is very loud and clear, hope it clears your doubts. You get the window to put your filepath and filename.

Mark as solution if this helps.

Thanks and Regards,
@hacky

Hi @hacky
Thanks. How to open the recently added files from particular folder.
Which activity i need to use for to open the files.

Hi ,

DateTime.Today will give you current date and time store it in a variable.

take a string array = Directory.GetFiles(“path of directory”)
Use for each loop to get all files from a directory and then use-

Directory.GetCreationTime(item).ToString

It will give you creation datetime for each file available in the path.

Then to get recently added file you can compare creation date time with current date time.

Or

You can store all creation datetime in a datatable and then sort it in descending order and then take first value.

Hello,

You can easily replace in command line
go to command prompt
type cd…
cd “your path”
rename *.xls *.xlsx
same way you can design a flow in studio

image

Cheers @vivek_sivam

Hi @vivek_sivam,

Take a look this package from UiPath Go to convert the file format.

Regards
Balamurugan.S

Hi @radhagangwani0
Thanks for your response.
Could you please create a flow for me.

1 Like

@vivek_sivam - share your email address, I will try to send the workflow…

Hi @radhagangwani0
Thanks.
In my case file have the xls format but inside the file it have html content so i can’t able to convert automate process. It is possible to open the particular folder and took the recently uploaded file then convert in to .xlsx file.
Can you please create a flow for this
My email: vivek.xtsdqa@gmail.com
Thanks

Hi @vivek_sivam

Use the below code to get the recent file in the folder

myFile = new DirectoryInfo(<yourFolderPath>).GetFiles().OrderByDescending(f => f.LastWriteTime).First();
1 Like

Hi @aanandsanraj
Thanks