Applescript - Search Folders/Files based on string and display in new FINDER WINDOW

I am trying to compile a script that will search based on a STRING and return all folders/files in a NEW SEARCH FINDER WINDOW. Is this possible?

This gives me a list on folders/files

set thePath to do shell script "find /Users/donwieland/Desktop/ -name ptw*”

/Users/donwieland/Desktop//FMP_MISC/ptw_order.fmp12 /Users/donwieland/Desktop//CLIENT FILES/PTW/PTW_Backup/ptw_data.fmp12 /Users/donwieland/Desktop//CLIENT FILES/PTW/PTW_Backup/ptw_lessons.fmp12 /Users/donwieland/Desktop//CLIENT FILES/PTW/PTW_Backup/ptw contact info.fmp12 /Users/donwieland/Desktop//CLIENT FILES/PTW/PTW_Backup/ptwonlin_sys_2022-02-24.sql /Users/donwieland/Desktop//CLIENT FILES/PTW/PTW_Backup/ptw_orders_test.fmp12 /Users/donwieland/Desktop//mData/PTW_doc/ptw_data_ddr /Users/donwieland/Desktop//mData/PTW_doc/ptw_data_ddr/ptw_data.html /Users/donwieland/Desktop//mData/PTW_doc/ptw_data_ddr/ptw_data_n.html /Users/donwieland/Desktop//PTW_Appts/ptw_lessons_ddr /Users/donwieland/Desktop//PTW_Appts/ptw_lessons_ddr/ptw_lessons_n.html /Users/donwieland/Desktop//PTW_Appts/ptw_lessons_ddr/ptw_lessons.html

now I want to open a new FINDER WINDOW and have these items listed. Similar to if a did a manual SEARCH.

Thanks in advanced.

Don

To get search results in a Finder window you are going to need to use the Finder to do the search.

It is a very easy task for AppleScript (+Cocoa).

use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
use framework "AppKit"

set aFolder to POSIX path of (choose folder with prompt "Select search target folder")
current application's NSWorkspace's sharedWorkspace()'s selectFile:(missing value) inFileViewerRootedAtPath:aFolder
set aResCode to current application's NSWorkspace's sharedWorkspace()'s showSearchResultsForQueryString:"ptw"

Applescript - Search Folders/Files based on string and display in new FINDER WINDOW
 
 
Q