How to delete specific PDF files by names?

I am looking for a process to delete a bunch of files in a folder by the string name so that only the PDF files that do not fit that naming convention remain. This is the file name PDF Export with bookmarks 2021-12-07 VBI that was created when i split a PDF it adds in a number value. I want to remove all of those but keep the ones with a person name.
image

Hi @jeff.shubzda

Check with the reference thread below!

Regards

Hi @jeff.shubzda

Use this syntax

Var_Array_of_String=Directory.GetFiles(“D:\test”)(specific your pdf directory)

pass the varr_Array_of_String in for each

Use if activity to check (“PDF Export”)
like this
item.ToString.Contais(“PDF Export”")

Inside the if activity use delete file and (pass the iterative variable item )
Thats it
Thanks,

hI @jeff.shubzda

Try with the for each file in the folder and condition to check and delete file
image

Hope this Helps

Regards
Sudharsan

1 Like

Hi,

Hope the following helps you.

img20211229-1

Regards,

1 Like

I added this into my workflow and when I connected it it threw errors?

Hi,

Can you try to set String at TypeArgument in ForEach activity?

Regards,

I’m sorry I’m not understanding the request? set string at?

Hi,

Can you modify object to String at the following property (red arrow)?

Regards,

Can you show the path which you used

Regards
Sudharsan

Also, Check once whether you have the files inside the folder and those are with correct extension

Regards
Sudharsan

Thank you to everyone who provided guidance, the bot works great and all the tips and tricks I will keep for another time. Happy New Year.

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