- Note: Search locations must be
indexed
by Windows
- Look in
Control Panel
for Indexing Options
import subprocess
query_string = 'file_name.png'
local_path = r'C:\Users\your_name\Pictures' # r is raw for dealing with backslashes
network_path = r'\\your\network\fold\path'
# for a network location
subprocess.Popen(f'explorer /root,"search-ms:query={query_string}&crumb=location:{network_path}&"')
#for a local folder
subprocess.Popen(f'explorer /root,"search-ms:query={query_string}&crumb=folder:{local_path}&"')
subprocess.Popen
is from the Python standard library Subprocess management.
search-ms:parameter=value[¶meter=value]&
is from MSDN Getting started with parameter-value arguments.
- Parameter-value arguments can be configured in a variety ways not exclusive to the way shown here. For example, folder will only locate local folders, but location will work for network and local folders.
f'some_string {variable}'
is from PEP498: Formatted String Literals.
explorer
& /root
are Windows commands.