Search in Folders


Search in Folders is a script command that simplifies searching for items within the selected folders whose names match a user-defined pattern.
Its main features are:

  • Since the command can be used in multiple places, the pattern can be defined textually, using the contents of the clipboard and even showing the user a prompt to enter text.
  • The pattern can be composed of several entries, separated by a user-defined character (default is new line).
  • (new in v1.0.1) Pattern can be typed, edited, readed from a text file or pasted from the clipboard in a multi line input string dialog window.
  • Use wildcards and regular expressions in the pattern, compatible with the syntax used by DOpus.
  • The command has arguments for case matching, regex usage, wildcard usage and partial matching.
  • Optionally the results can include folders.
  • (new in v1.0.2) Define the folders from which the search will be performed from the same command.
  • (new in v1.0.2) Optionally, Everything can be used to perform the search.

Download the file below. Then run Prefs SCRIPTINSTALL and select the downloaded file.
:warning: IMPORTANT: Needs at least v13.0.45
Search in Folders.js.txt (9.0 KB)

You can use Search in Folders as an additional command, using SearchFolders.


Argument Type Description
CASE /S Use for make the search case sensitive.
EVERYTHING /S Use voidtools Everything to perform the search. Note that you can then use Everything's own syntax and search using values with or without wildcards, in a mixed manner.

e.g. PATTERN *.txt;name (1) SEP=; would search for both values.

FOLDERS /S Use to include folders in the results. By default, the command searches for files only.
IN /K/M By default the command will use the selected folders in source to search. Use IN for specify the folder or folders to search instead. Note that if the paths contain a space, you must enclose the value in quotes.
NOPARTIAL /S Use to prevent partial name matching.
NOWILD /S Use to prevent wildcard name matching in regular search. Note that CASE, NOWILD, REGEX and NOPARTIAL affects all the values in pattern, so for example, you will not be able to mix values with wilcards and without them in the pattern.

e.g. PATTERN *.txt;name (1) SEP=; can't search for both values simultaneously with the normal search. NOWILD allows you to use name(1), but *.txt will no longer work. For that kind of cases, use EVERYTHING is recommended.

PATTERN /O /R The value to be used as a pattern to search for. You can include several entries in a same pattern, each separated by SEP value.

e.g. SEP=; PATTERN *.txt;*.xml;blah will search for all items whose name matches with *.txt, *.xml or blah.

If PATTERN is included without value, or omitted from command line, text input is enabled from a dialog box, with multiline support, text file loading, and editing. Note that PATTERN is a raw value, means must be used at last, since the rest of the command line following the argument name is taken as the value.

REGEX /S Enables regular expressions.
SEP /K The value to be used as a separator for PATTERN, when several patterns are provided. If not included, the default separator will be Windows line break (\r\n).

Use clipboard content as pattern, which contain several lines:
SearchFolders PATTERN {clip}

Use a user defined string by a dialog as a pattern, separated by semicolon. Make the search case sensitive and include folders.
SearchFolders CASE FOLDERS SEP=; PATTERN {dlgstring|Pattern:}

Display a dialog box that allows you to load a text file with one filename per line, and then edit the loaded text.
SearchFolders or SearchFolders PATTERN

Use Everything to search all jpg files in C:\my images and D:\my images.
SearchFolders IN "C:\my images" "D:\my images" EVERYTHING PATTERN ext:jpg

Use Everything to search all jpg files in C:\ and D:\ with a defined height (may require Everything v1.5)
SearchFolders IN C:\ D:\ EVERYTHING PATTERN ext:jpg height:{dlgstring|Height to search:}

v1.0.3 (2023-11-15):

  • In a regular search, if a value from pattern contains *, NOWILD is ignored for that particular entry.

v1.0.2 (2023-11-14):

  • Added IN argument to specify folders to search instead of selected.
  • Added EVERYTHING argument to use Everything for searching.

v1.0.1 (2023-11-14):

  • PATTERN is now an optional, raw type argument. If omitted or used by itself, it allows the pattern to be entered later in a multiline dialog box, with support for text files load and editing.

v1.0.0 (2023-11-13) : Initial release


Thank you, thank you! You completed that much quicker than I anticipated.

I tested my alpha test use cases. It found what I expected:
SearchFolders PATTERN {clip}
SearchFolders CASE SEP=; PATTERN {dlgstring|Pattern:}
SearchFolders SEP=; PATTERN {dlgstring|Pattern:}
SearchFolders PATTERN {dlgstring|Pattern:}

I will definitely be using this as I find it a better workflow for searching multiple subfolders in a folder.

v1.0.1 is up! Now you can load text files or paste content from the clipboard directly from the script!

can't find the directories themselves?
and files like this too "Multi-line search (1)"

What do you mean by that? Can you give an example?
If you mean including folders in the results, use FOLDERS as an argument. (Read the main post)

For that, include NOWILD (Again, the main post...)

1 Like

v1.0.2 is up to test!
IN and EVERYTHING arguments have been added. So now you can get search results much faster!

v1.0.3 is up!


I like to imagine that my earlier request for a feature for this script sparked a creative surge in you to continue updating this script without external requests. Regardless of the accuracy of my fantasy, I have another feature request. I iterate that as I don't know scripting in DO, I don't know how my request is to implement.

  1. Remember the last used command
  2. Search in Source, as well as selected folders in Source as is the case now

I don't ask for much! Ha. :wink: TIA

PS Thanks especially for the EVERYTHING addition

If you run the command using >, then you can access the last command line.

You can define folders to search using IN argument. So for that, use IN {sourcepath} {allfilepath}, asumming you're selecting folders only. FWIW, searching in source path and in selected folders in source will be redundant, but the possibility is there.

Thanks for 1. That makes me think of a dropdown history list of prior commands

I didn't state my request in 2. clearly. What I had in mind was the ability to search the file names in Source for the input text. TIA

SearchFolders IN {sourcepath} SEP=; PATTERN value 1;value 2...


SearchFolders IN {sourcepath} 

will let you enter the input text later in a nice dialog window (or even paste from clipboard or read text from a file)

Add FOLDERS to include subdirectories in the results as well. You can also use all the available args for that matter.

PS: If you run into any trouble, or just want to see the command line generated plus some info, just do Prefs SCRIPTS="Search in Folders.js*" and set DEBUG to ALL :wink:

Thank you for your efforts and patience. I did get where I was aiming.

Screen 23-11-15 10_13_27PM