Rename dynamic filename with first 41 characters from name

Hi,

is there a posibility to rename a file like this:
monitor_export_name-or-name-name_20190330_20200428-10.xls
into a name with first 41 characters and add xls?

monitor_export_name-or-name-name_20190330.xls

thanks,
Cosmin

@Cosmin_Cirnu - you can use substring option to extract the no of characters like

NewString = myString.Substring(0, 41);

to rename - use FileCopy activity and pass the current file name from and newsString as the new file name to…
or
you can try to rename file with below uipath component… pls follow instructions to install…
filename as original… rename with substring value…

3 Likes

Hi
thanks for your help.
i put file.Substring(0, 41) in a move file but it seems it was erased from right to left and .xls dissapeared also
monitor_export_n
any idea how to make to invert from left to right?
keep in mind that the number of characters that need to be deleted is variable as below:
monitor_export_name-or-name-name_20190330_20200428-10.xls
monitor_export_name-or-name-name_20190330_20200428-1.xls
monitor_export_name-or-name-name_20190330_20200428.xls

Thanks,
Cosmin

@Cosmin_Cirnu - pls try below

Left(file.Replace(".xls","").ToString,41) + “.xls”

input - “monitor_export_name-or-name-name_20190330_20200428-10.xls”
output - monitor_export_name-or-name-name_20190330.xls

2 Likes

Thanks a lot!
Cosmin

1 Like

@Cosmin_Cirnu - cheers!!

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.