On Oct 27, 2014, at 03:53, [email protected] wrote:
> Cant understand why a multi file search using text factory in BBE won't allow 
> the results to go into a new window.
______________________________________________________________________

Hey Mark,

At the risk of being pedantic.  :)

If I read the manual correctly it's because they're specifically designed to 
process the selected text OR the full text of the front BBEdit text document OR 
the contents of files on-disk.  Essentially a Text-Factory is a Text-Filter 
with a limited scope of operations.

I looked to see what might be done with an AppleScript within a Text Factory, 
but it seems only the text gets passed.  So with AppleScript you could produce 
some output based on the file content, but you could not produce the file-path.

I believe the same will be true of shell scripts within a Text Factory.

BBEdit has other tools for producing a list of files containing literal text or 
a regular expression.

`bbfind`, Multi-File Search, and AppleScripted Multi-File Search (aside from 
shell access and the plethora of tools that makes available).

Attached is an AppleScripted Multi-File Search with some extras.

If you look in the variable findReco you can see there's quite a lot of info 
available on matched items.

So.  With all the available tools you can really go to town once you learn the 
way.

--
Best Regards,
Chris

-------------------------------------------------------------------------------------------
set targetFolder to alias 
"Ryoko:Users:chris:test_directory:folders_nested_replace:"

set searchStr to "I want my MTV!"

tell application "BBEdit"
  set findReco to find searchStr searching in targetFolder ¬
    options {search mode:grep, case sensitive:false, returning results:true} ¬
    recursion true ¬
    with text files only
  
  if found of findReco = true then
    set fileList to {}
    repeat with i in found matches of findReco
      set _file to result_file of i
      if _file is not in fileList then # Filters out duplicates
        set end of fileList to _file
      end if
    end repeat
  else
    error "No files with found containing the given regular expression!"
  end if
  
  # These methods of removing duplicates are unnecessary, because I've filtered 
out dupes
  # as they're added to 'fileList'.
  # I leave them to demonstrate various other techniques.
  
  # Vanilla AppleScript to remove duplicate file paths.
  # set AppleScript's text item delimiters to linefeed
  # set fileList2 to (do shell script "sort -u <<< " & quoted form of (fileList 
as text))
  
  # Using the Satimage.osax { http://tinyurl.com/dc3soh } to remove duplicate 
file paths.
  # set fileList3 to join (sortlist fileList with remove duplicates) using 
return
  
  # Using BBEdit itself to remove duplicate file paths.
  set AppleScript's text item delimiters to return
  set filePaths to fileList as text
  set filePaths to unique lines of (process duplicate lines filePaths output 
options {deleting duplicates:true})
  
  make new document with properties {text:filePaths, bounds:{0, 44, 1314, 1196}}
  
end tell
-------------------------------------------------------------------------------------------
tell application "Finder"
  # delete in this context sends files to the Trash rather than destroying them 
as `rm` does.
  # Commented out to prevent accidents.

  # delete fileList
end tell
-------------------------------------------------------------------------------------------
Tags: @BBEdit, @AppleScript, @Shell, @Script, @Multi-File-Search, @Search, 
@Text_Factory, @Factory
-------------------------------------------------------------------------------------------

-- 
This is the BBEdit Talk public discussion group. If you have a 
feature request or would like to report a problem, please email
"[email protected]" rather than posting to the group.
Follow @bbedit on Twitter: <http://www.twitter.com/bbedit>

--- 
You received this message because you are subscribed to the Google Groups 
"BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].

Reply via email to