Recursive search in selected directory for string inside .ms scripts and finally double click on item in list of matches result to load the script for editing.

Script
Find Script By String
By Anubis · 2009-06-28
- Version
- 1.0
- Version requirement
- 3ds Max 2009
- Date updated
- 2009-06-28
- Votes
- 17
- Homepage
- http://project3d.narod.ru
Description
Attachments
- FindScriptByString.ms — FindScriptByString.ms1.9 KB
Tags: edit, search, file load, findString, string, inside .ms
Comments (4)
Nik · 2018-11-28
Круто, спасибо. Но не работало для вводимого пути напрямую. Немного подкорректировал.
Cool, thanks. But it did not work for the input path directly. A little tweaked.
-- Find Script By String v.1.0 [2009-06-27]
-- by Karabakalov (Anubis) anubiss@abv.bg
if findScriptDlg != undefined then destroyDialog findScriptDlg
rollout findScriptDlg "Find Script By String" width:800 height:600
(
local allMSfiles = #()
local result = #()
-- UI items
edittext ed_currDir "" width:746 across:2
button bt_srcDir "..." height:18 align:#right
edittext ed_search "" width:773
multiListBox mlb_files "" width:773 height:40
label lb_result "Enter string to search..."
-- Functions
fn getFilesRecursive root pattern =
(
dir_array = GetDirectories (root+"/*")
for d in dir_array do
join dir_array (GetDirectories (d+"/*"))
join dir_array (GetDirectories root)
my_files = #()
for f in dir_array do
join my_files (getFiles (f + pattern))
my_files
)
fn searchFn = (
result = #()
setWaitCursor()
for f in allMSfiles do
(
s = openFile f
while not eof s do
(
find = readLine s
if findString find ed_search.text != undefined then
(append result f ; exit )
)
close s
result
)
lb_result.text = (result.count as string) + " files found"
if result.count > 0 then
(mlb_files.items = result ; lb_result.text += " -- Double Click to Edit...")
setArrowCursor()
)
-- Events
on ed_search entered txt do
(
if txt != "" then searchFn()
else lb_result.text = "Enter string to search..."
)
on ed_currDir entered txt do
(
d = ed_currDir.text
allMSfiles = getFilesRecursive ed_currDir.text "*.mcr"
)
on bt_srcDir pressed do
(
d = getSavePath caption:"Where to Search..." initialDir:"$scripts"
if d != undefined then
(
ed_currDir.text = d
allMSfiles = getFilesRecursive ed_currDir.text "*.ms"
)
)
on mlb_files doubleClicked itm do
if mlb_files.selection != 0 then edit mlb_files.items[itm]
on findScriptDlg open do
(
ed_currDir.text = (getDir #scripts)
allMSfiles = getFilesRecursive (getDir #scripts) "*.ms"
)
)
createDialog findScriptDlg style:#(#style_titleBar, #style_border, #style_sysMenu, #style_minimizeBox)
br0t · 2013-05-08
I like :)
kilad · 2013-05-07
hm. Have you tried ctrl + shift + F in mxs editor?
Cool
Nevil · 2013-05-06
This is great idea and useful tool.