Media_Search ( location_and_mask { ; meta_pattern } )
Searches a specified location for multimedia files and returns a list of paths matching given search criteria. Files can be matched either by their file name (specified in the first argument) and/or by their metadata contents (specified in the second argument).
Parameters
Parameter | Description |
---|---|
location_and_mask | A list of paths where to start, optionally containing a file name mask. |
meta_pattern | Optional. A regular expression to search metadata for. |
Discussion
The function prints recursively all files from the specified location, optionally filtering out all but those matching a mask. When the second argument is present, metadata of all files matching the mask will be matched with a regular expression (regexp) and only those satisfying the regexp will be printed by the function.
File name mask. If the mask is not present, it defaults to “*.*” without the quotes. Otherwise you can use * to match zero to any number of characters or ? to match exactly one character. Usually the mask contains *.file_extension so *.mp3 matches all MP3s. You can specify multiple masks by delimiting them with a pipe (“|”) character so that “*.mp3|*.wav” specifies both MP3s and WAVs.
Meta pattern is a case insensitive regular expression conforming to the ECMAScript regular expression standard. When constructing a search pattern, you can use an online regexp debugging sites such as https://regexr.com or https://regex101.com.
Returns
A list of paths of files matching the criteria.
Examples
Search the Music folder in the user’s home directory for all MPEG-4 AACs:
MyTable::Response ;
Media_Search ( ".m/*.m4a|*.aac" ) ]
Search the Documents and Downlads folder for all MP3s containing “Vangelis” at their metadata:
MyTable::Response ;
Media_Search ( ".m/*.m4a|*.aac" ; ".*Vangelis.*") ]
Search the Documents folder for all MP3s, WAVs, MPEG-4 AACs containing “
MyTable::Response ;
Media_Search ( ".d/" ; ".*Vangelis.*") ]