How to Swap the letters on the saved pdf names

Hi Team,

Say for example my pdf file name is saved in the directory like below

Automation_AK6752_Letter_20052022.pdf

So I want to keep all the last numbers in the beginning and rename all the pdf files which ever is saved in the directory like below

20052022_Automation_AK6752_Letter.pdf

How do I achieve this

Split (Automation_AK6752_Letter_20052022.pdf).Replace(“.pdf”,"') using “_” and you get an array say splitarray

updated pdf name -splitarray(3)_splitarray(0)_splitarray(1)_splitarray(2).pdf

1 Like

Hi @bhanupriya.cb ,

Did it work?

@bhanupriya.cb priya.cb

Try this workflow:

Main.xaml (9.8 KB)

@bhanupriya.cb

This are below expression you have to used:

1.  split(PDF,regex.Match(PDF,"(?<=Letter)_[\d]+").ToString)
2.  (PDF.Split("_"c).Last.ToString.Split("."c).First)+"_"+Final

Hi Thanks for ur reply, it is working fine only for the example which i sent to you but i need to get the pdf files from the path and do it for all the pdf’s wch ever is saved in path…
but i tried as below it is throwing an error

assign : Directory.GetDirectories(“\172.22.192.91\corpgs\CFO_ORG\Tax\Income-Tax\India\MINDTREE\E filing screenshots\Output_27_05_2022”)

Hi,

Can you try as the following sample?

System.Text.RegularExpressions.Regex.Replace(System.IO.Path.GetFileNameWithoutExtension(CurrentFile.Name),"^(.*?)_(\d+)$","$2_$1")

Regards,

Hi Thanks for your reply, can you send me this workflow

Hi,

Here you are.

Sample20220530-1a.zip (2.7 KB)

Regards,

Hi

image

It is showing as missing or invalid activity :frowning:

Hi,

Which version of Studio do you use? Did you open the above sample as project?

Anyway, can you try the following? This compatible with Studio 21.10.6.

Sample20220530-1av2.zip (2.7 KB)

Regards,