Loading ...
Sorry, an error occurred while loading the content.
 

[Clip] Re: Search and open

Expand Messages
  • Hans Tolboom
    Hi Jody, i ve already started all over again. I think this works but I want to know if someone knows another way to parse the info in %files% ? Right now I had
    Message 1 of 7 , Feb 26, 2000
      Hi Jody,

      i've already started all over again. I think this works but I want to know
      if someone knows another way to parse the info in %files% ? Right now I had
      to put the contents of %files% in a document and parse the document.

      Hans

      PS : Dirsearch script copied from NoteAwk 4.25

      test
      ;
      ; Search for files and open them
      ;

      ^!TOOLBAR:NEW DOCUMENT

      :init
      ; Wizard to create a disk directory command
      ^!SetWizardTitle Disk Directory
      ^!SET DIRCOM=^$GetShort(^?[(T=D)Directory])$
      ^!SET %dir%=^$StrUpper(^%DIRCOM%)$
      ^!SET DIRCOM=^%DIRCOM%^?[Files of Type=_All^=*.*|Text Files^=*.txt|GIF
      Files^=*.gif|MP3 Files^=*.mp3]
      ^!SET DIRCOM=^%DIRCOM%^?[Recurse Subdirectories=_No^= |Yes^= /S]
      ^!SET DIRCOM=^%DIRCOM%^?[Bare Format (No headings or summary)=No^= |_Yes^=
      /B]

      :findfiles

      ; Put files in array
      ^!SetArray %Files%=^$GetDosOutput("dir ^%DIRCOM%")$

      ; Count number of files
      ^!Set %numfiles%=^$StrCount(^%dir%;^%Files%;False;False)$

      ; [TO DO] if numfiles > 100 ask for input

      ; Put result in temporary document
      ^%Files%

      ; Jump to new document
      ^!Document LAST

      ^!Set %i%=1
      :execute
      ^!IF ^%i% > ^$GetLineCount$ end
      ^!Set %tmp%=^$GetLine(^%i%)$

      ; skip it all if line is empty
      ^!IF ^$IsBlank(^%tmp%)$ SkipOpen

      ; add drive letter if not present
      ^!IF ^$StrCopy(^%tmp%;1;3)$ = ^%dir% SkipAdd ELSE DoAdd
      :DoAdd
      ^!Set %tmp%=^$StrInsert(^%dir%;^%tmp%;0)$
      :SkipAdd
      ^!Open ^%tmp%

      :SkipOpen
      ^!Inc %i% 1
      ^!Goto execute

      :end
      ; select and destroy last document
      ^!Document LAST
      ^!DestroyDoc
    • Jody
      Hi Hans, ... Here s a section out of my DirStuff with some options snipped out from between the lines: ^!Set %OutPut%=^$GetDosOutput(Dir ^%DosOptions%
      Message 2 of 7 , Feb 27, 2000
        Hi Hans,

        > i've already started all over again. I think this works but I
        > want to know if someone knows another way to parse the info in
        > %files% ? Right now I had to put the contents of %files% in a
        > document and parse the document.

        >^%Files%

        Here's a section out of my DirStuff with some options snipped out
        from between the lines:

        ^!Set %OutPut%=^$GetDosOutput(Dir ^%DosOptions% "^%Folder%^%Type%")$
        ^!IfTrue ^$IsEmpty("^%OutPut%")$ Error
        ^!IfTrue ^%FullPath% Next else Skip_2
        ^%AddPath%^$StrReplace("^p";"^p^%AddPath%";"^%OutPut%";0;0)$
        ^!DeleteLine
        ^!Goto Skip
        ^%OutPut%

        I use many methods in the Library to work with directories. The
        reasons are for learning, for testing the methods to see what is
        fastest, and boredom of doing it the same way all the time. ;)
        The Library does a number of things like changing the case of the
        files in a folder, opening a checkbox to open selected files with
        an option to have the boxes pre-checked or not, switches to a
        certain tab from a list or closes files via a checkbox, inserts
        files from a directory, appends to a file (whole folder),
        converts a folder of HTML files to .txt files, and some others.
        I even though in WinZip support and setup at no extra charge.

        Here is the latest I just added which I found is the fastest
        method yet using the new ^$GetFiles(...)$ function and seems to
        require the least resources. I left all the directory GetValues
        in that my setup does in hoping you will get thirsty and try out
        DirStuff so perhaps you can get some ideas or send some my way.

        http://www.sureword.com/notetab/html/library.html

        You might just want to download it if the lines get all messed
        up. Hey, check out what I just added. It gives a file count
        instead of opening per file type(s). Super Fast, as in lickety
        split!!! It did my Windows\System (961 files) in about a second.

        <--- Copy below this line --->
        H=Open Directory 2... 4.8 Fastest, but cannot do subdirectories.

        ; v4.8, 02-26-2000, Sojourner@..., jody
        ; http://www.sureword.com/notetab/zip/dirstuff.zip

        ^!Continue Opens all files in a folder, faster than DOS, but cannot do sub-directories. Continue?

        ^!ClearVariables
        ; a tad bit long <g>
        ^!Set %Folder%=^?{(T=D)&Browse: full path, end in backslash=^$GetValue(DirStuff:Browse)$}; %Drop%=^?{&Drop down: full path, end in backslash=_If used, Browse is ignored^=1|^$GetValue(DirStuff:Path1)$|^$GetValue(DirStuff:Path2)$|^$GetValue(DirStuff:Path3)$|^$GetValue(DirStuff:Path4)$|^$GetValue(DirStuff:Path5)$|^$GetValue(DirStuff:Path6)$|^$GetValue(DirStuff:Path7)$|^$GetValue(DirStuff:Path8)$|^$GetValue(DirStuff:Path9)$}; %Type%=^?{(H=10)File &Types, wildcards OK: *.txt or *.*htm*;*.txt=*.bmp|All Files^=*.*|Html Only^=*.*htm*|_Text Only^=*.txt|Html & Text^=*.*htm*;*.txt|Outline^=*.otl|Clipbook Library^=*.clb|Ini^=*.ini}; %Display%=^?{==_Display in new document^=|Display in info box^=1}; %Atrb%=^?{&Attributes, A: Archive, H: Hidden, R: Read-only, S: System=_All^=|AHRS}; %Sort%=^?{&Sort order=Date|_Name|Size|Type|UnSorted}; %Rev%=^?{&Reverse sort order=Yes^=Rev|_No^=}; %FileCnt%=^?{Get number of files only=Yes|No}

        ^!SetHintInfo Opening Files...

        ; Checks to see if Browse or Drop was used
        ^!IfTrue ^%Drop% Skip
        ^!Set %Folder%=^%Drop%

        ^!SetListDelimiter ^p
        ^!SetArray %OpenList%=^$GetFiles(^%Folder%;^%Type%;^%Atrb%;^%Rev%^%Sort%)$
        ^!Set %Count%=^%OpenList0%
        ^!Set %Index%=0
        ^!Set %OpenCount%=0

        :Loop
        ^!SetScreenUpdate Off
        ^!Inc %Index%
        ^!If ^%Index% > ^%Count% Stats
        ^!IfTrue ^%FileCnt% Skip
        ^!Open ^%OpenList^%Index%%
        ^!Inc %FileCount%
        ; ^!StatusShow Opened File #^%OpenCount%
        ^!Goto Loop

        :Stats
        ^!SetWizardTitle ~^$StrFill(" ";20)$www.sureword.com/notetab^$StrFill(" ";20)$~
        ^!Info [L]^%Folder%^p^%Type%^p^%FileCount%^p^%Sort%^%Rev%^p^$StrFill("¯";^$StrSize("^%Sort%^%Rev%")$)$^p^%Atrb%

        <--- Copy above this line, right --->
        <--- click over a Library, and --->
        <--- choose "Add from Clipboard" --->

        Happy Clip'n!
        Jody

        http://www.sureword.com/notetab

        Subscribe, UnSubscribe, Options
        mailto:Ntb-Clips-Subscribe@...
        mailto:Ntb-Clips-UnSubscribe@...
        http://www.egroups.com/list/ntb-clips
      • Eb Guenther
        Hi Hans, ... If I understand you correctly, you want to open only specific files according to some filename pattern. Here is how I would approach this (winding
        Message 3 of 7 , Feb 27, 2000
          Hi Hans,

          >i've already started all over again. I think this works but I want to know
          >if someone knows another way to parse the info in %files% ? Right now I had
          >to put the contents of %files% in a document and parse the document.

          If I understand you correctly, you want to open only specific
          files according to some filename pattern.

          Here is how I would approach this (winding up with a list of
          full path files in the array ^%filelist%:


          ;long line
          ^!Set %searchpattern%=^?{For filename search pattern replace any of the
          "?"s with significant characters=??????*.???}
          ;end long line
          ^!Set %Folder%=^?{(T=D)Browse to starting directory=C:\temp\}
          ^!Set %filespec%=^%Folder%^%searchpattern%
          ^!SetArray %filelist%=^$GetDosOutput("dir ^%filespec% /s /b /x")$
          ^!Info [L]^%filelist%


          You can now process the files, one by one, by looping
          through the filelist array. You could try long filenames,
          in which case, just remove teh "/x" switch.

          Good luck,

          Eb
        • Norma
          Hi Pat. I added a little bit of code to your McTagit clipbook and thought I would share it in hopes that you or someone else may find it useful. All I did is
          Message 4 of 7 , Feb 27, 2000
            Hi Pat. I added a little bit of code to your McTagit clipbook and thought I
            would share it in hopes that you or someone else may find it useful. All I
            did is rename one of the functions you had so that it could be used by my 2
            added clips functions. They in turn reduce categories since often I get so
            many different categories and at times a few different names for the same
            type of categories in my recipes and felt the need to clean them up. One is
            for Mastercook and the other is for Meal Master.

            Regards,
            Norma

            H="Pick_Categories"
            ;Change default delimiter to a comma space
            ^!SetWizardTitle "Pick All that Apply"
            ^!SetListDelimiter ", "
            ;Display checkbox list from top.
            ^!Info
            ^?{(T=A)Prompt=Appetizers^=Appetizers|Beverages^=Beverages|Breads^=Breads|Breakfast^=Breakfast|Candy^=Candy|Casseroles^=Casseroles|Crockpot^=Crockpot|Chefs/Profs^=Chefs/Pros
            |Condiments^=Condiments|Cookies^=Cookies|Dips^=Dips|Dairy^=Dairy|Desserts^=Desserts|Entrees^=Entrees|Ethnic^=Ethnic|Fish
            and Seafood^=Fish and Seafood
            |Fruit or Nuts^=Fruit or
            Nuts|Grilling^=Grilling|Holiday^=Holiday|Information^=Information|Meats^=Meats|Microwave^=Microwave|_New
            Import^=New Import|Pasta^=Pasta
            |Poultry^=Poultry|Salads and Dressings^=Salads and Dressings|Sandwiches and
            Wraps^=Sandwiches and Wraps|Soups^=Soups|Soyfoods^=Soyfoods|Special
            Diets^=Special Diets|Vegetables^=Vegetables|Vegetarian^=Vegetarian}
            ^!InsertText ^%T%^P



            H="Reduce/Add Categories -MC"
            ^!Find "Categories"
            ^!Select Line
            ^!IfTrue ^$IsEmpty("^$GetSelection$")$ Exit
            ^!Keyboard DELETE
            ^!InsertText Categories :
            ^!Clip Pick_Categories

            H="Reduce/Add Categories -MealMaster"
            ^!Find "category"
            ^!Select Line
            ^!IfTrue ^$IsEmpty("^$GetSelection$")$ Exit
            ^!Keyboard DELETE
            ^!InsertText " category: "
            ^!Clip Pick_Categories
          • Norma
            There s a mistake in the Mealmaster version, I fixed it here (I had some recipes in old MM format the former was based on) and I made the Mastercook one
            Message 5 of 7 , Feb 27, 2000
              There's a mistake in the Mealmaster version, I fixed it here (I had some
              recipes in old MM format the former was based on) and I made the Mastercook
              one better. Some Mastercook categories are on more than one line (instead
              of just one line I thought they were before). Sorry about that.
              Norma

              H="Reduce/Add Categories -MC"
              ^!ClearVariable %Start%
              ^!ClearVariable %End%
              ^!Find "Categories :"
              ^!IfError End
              ^!FocusDoc
              ^!Jump Select_Start
              ^!Set %Start%=^$GetRow$:^$GetCol$
              ^!Find " Amount" IS
              ^!IfError End
              ^!Jump Select_Start
              ^!Set %End%=^$GetRow$:^$GetCol$
              ^!SetCursor ^%Start%
              ^!SelectTo ^%End%
              ^!Keyboard DELETE
              ^!InsertText Categories :
              ^!Clip Pick_Categories
              ^!Keyboard ENTER

              H="Reduce/Add Categories -Meal Master"
              ^!Find "Categories:"
              ^!IfError End
              ^!Select Line
              ^!Keyboard DELETE
              ^!InsertText " Categories: "
              ^!Clip Pick_Categories
            Your message has been successfully submitted and would be delivered to recipients shortly.