Copy files with conditions to folders

I have folders of files that have subdirectories (more than 10)…
And I only want files with name contains “TB” or “*.XLS” files to be move to the folder.

How do I do that?

HI @Uioptimusprimeolive

welcome to community!

Use for Each file in folder activity

Filter → “*.xls”

Use move activity

Look into the screenshot

Regards
Gokul

To get file extension you can using :
System.IO.Path.GetExtension(yourFilePath) Or GetExtension(yourFilePath)

To Check is an string contain other string :
yourStringToCheck.Contains(stringToFind)

You can also try
1.Assign files=Directory.GetFiles(folderpath,pattern)
folderpath=folder path in which you want to search files as “c:/imporant files”
pattern=give pattern as “.xls”
2.Iterate files as foreach with type argument as string.

Hi @Uioptimusprimeolive ,

Could you try this?
Assign →

str_Folderpath = "Folder path"
Directory.GetFiles(str_FolderPath,"*.*").Where(Function(w) System.Text.RegularExpressions.Regex.IsMatch(w,"(TB)|(\.xls(?=$))")).ToArray()

Kind Regards,
Ashwin A.K

image
I did this but nothing happen

sorry I am new to this.

How should I apply the code into which tools?

I am coming from Alteryx and Power Automate background

Hi @Uioptimusprimeolive

Here is the workflow

NewBlankTask.zip (176.7 KB)

Regards
Gokul

Hi!

Thanks for the prompt reply!

I tried playing around with your flow, and encounter some questions

image

Why cant I edit the <[CurrentFile.Extension.ToString.Equals(".xls")]> to <[CurrentFile.Extension.ToString.Contains(".xls")]>

It seems like it doesnt allow me to do so.

Hi @Uioptimusprimeolive

Equal → Exact output (Checks whether two variables are equivalent)

Contains → InExact word (The words contains in the variable)

Regards
Gokul

I mean how do you type it into here
image

Try it in this way @Uioptimusprimeolive

After some tweaks, i can get the files i want and rename it!

Thanks!

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