Finding a file/directory name that contains chosen text


I am trying to find out if a directory/file name contains text.

I have been going through the Scriptable Docs and I could well be wrong but I cannot find anything on this?

I suppose I could do this within Shortcuts but I am trying to keep the script together and not keep going to and from

You mention “chosen” text in the title? Are you maybe just looking to do a regular expression match or an include() check against the file and directory names in a list or an array? They would be general JavaScript methods rather than specific to Scriptable.