Delete files with certain words in the name

Hello all,

I have a process that uploads image files.
I use a get file list for it but I need to delete image files that contain “new image” in the file name.

How would i make such a process?

@dvn If the Images are contained in a Folder, you can use :
Directory.GetFiles(yourFolderPath) to get the files in that folder.

Then using an If condition you can check whether there is “new image” in the name, If present you can use Delete File Activity

Afraid i dont get it.
What kind of condition would i write in the IF part and what would i write for the Delete File activity?

@dvn Sorry I missed the part that you’ll need to use For Each of the Output of Directory.GetFiles() which will be an array of String :sweat_smile:

The Workflow will look Something like this :
Assign : strArray = Directory.GetFiles(yourFolderPath)
For Each item in strArray
if item.ToString.ToLower.Contains(“new image”)
Delete File Activity
leave Blank

1 Like

Hi , Thaks for your report ! How can we do if we want to not delete if contains…

Just put the ‘delete file’ activity on the other side of the if condition…

Hello Dubhan,
In this video I do a lot of stuff with Files:

1:10 Download the file and Move the latest file to folders
4:30 Rename files with VB commands
6:00 Move files to do Rename
6:55 Delete files
8:15 Delete only PNG files
8:55 Delete all the files except PNG files
9:55 Move files
11:10 Delete files that are older than 2 weeks
14:40 Create a file or folder with dates inside
17:00 Trigger a process when the file is added to a folder
18:45 How to use the files start the process
20:30 Excel Application Scope use files

Cristian Negulescu