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

How to follow directory tree?

Expand Messages
  • Ray Tomes
    Greetings All I am new to this NoteTabbing and still very much learning my way around. I want to know how to follow a directory tree, that is to find the names
    Message 1 of 9 , May 2 7:45 PM
      Greetings All

      I am new to this NoteTabbing and still very much learning my way
      around. I want to know how to follow a directory tree, that is to find
      the names of the directories within a directory as well as the files.
      Below is my simple file list from a directory, how would I change this
      to show the directories in a selected directory? I could do a DOS
      "DIR" command to a file and read it back, but I am wondering if there
      is a more elegant way.

      BTW, I only have NoteTab Lite, so please keep to functions that work
      in that.

      Regards

      Ray Tomes

      H="show files in dir"
      ^!Set %dirn%=^?[(T=D)Directory=]
      ^!InsertText Directory=^%dirn%^p
      ^!Set %filen%=^$GetFileFirst(^%dirn%;*;name)$
      :StartLoop
      ^!InsertText ^%filen%^p
      ^!Set %filen%=^$GetFileNext$
      ^!IfFileExist ^%filen% StartLoop
      ^!CloseFileFind
    • Sheri
      ... Hi Ray, There are no limitations with respect to the clip language in Notetab Light. However, Pro includes syntax highlighting for clip editing, and
      Message 2 of 9 , May 3 7:44 AM
        At 02:45 AM 5/3/03 +0000, Ray wrote:
        >I am new to this NoteTabbing and still very much learning my way
        >around. I want to know how to follow a directory tree, that is to find
        >the names of the directories within a directory as well as the files.
        >Below is my simple file list from a directory, how would I change this
        >to show the directories in a selected directory? I could do a DOS
        >"DIR" command to a file and read it back, but I am wondering if there
        >is a more elegant way.
        >
        >BTW, I only have NoteTab Lite, so please keep to functions that work
        >in that.
        >
        >Regards
        >
        >Ray Tomes
        >
        >H="show files in dir"
        >^!Set %dirn%=^?[(T=D)Directory=]
        >^!InsertText Directory=^%dirn%^p
        >^!Set %filen%=^$GetFileFirst(^%dirn%;*;name)$
        >:StartLoop
        >^!InsertText ^%filen%^p
        >^!Set %filen%=^$GetFileNext$
        >^!IfFileExist ^%filen% StartLoop
        >^!CloseFileFind

        Hi Ray,

        There are no limitations with respect to the clip language in Notetab Light. However, Pro includes syntax highlighting for clip editing, and clipbars for launching clips, both of which make clip operations more convenient. That said, clips that will be run on both platforms still need to be tested on both because the behavior of some clip functions and commands, notably ^$GetLine$ and ^!Select Line, is slightly different.

        Feel free to use my Clip Syntax clips, which work fine in Light. Get ClipcodeSyntax_v4.02.zip from the groups file area:

        http://groups.yahoo.com/group/ntb-clips/files

        The problem of getting and processing subdirectories is one I've struggled with before. I also suggested that the ^$GetFiles function be enhanced to support attribute "D" for directory when specified. Other normal file attributes work, but "D" doesn't.

        I did find that using the DOS command worked best, although it presented problems with accented characters in directory names (which I finally solved). Below is my clip which gets directories, plus a version of your clip that makes use of mine.

        Regards,
        Sheri

        H="SpecFolders"
        ^!Set %agdrv%=^?[(T=D);Browse to Desired Folder]
        ^!Set %agfolders%=^%NL%
        ^!Append %agfolders%=^$GetDosOutput(dir "^%agdrv%" /ad /b)$
        ^!Set %agfolders%=^$StrReplace("^P^P";"^P";"^%agfolders%";No;No)$
        ^!Set %agfolders%=^$StrTrim(^$StrAsciiToAnsi("^%agfolders%")$)$
        ^!Set %agfolders%=^$StrReplace("^P";"^P^%agdrv%";"^%agfolders%";No;No)$
        ;^!InsertText ^%agfolders%

        H="show files in dir"
        ^!Clip SpecFolders
        ^!SetListDelimiter=^P
        ^!SetArray %Folders%=^%agfolders%
        ^!Set %count%=0
        :Folder
        ^!Inc %count%
        ^!If ^%count%>^%Folders0% Out
        ^!Set %dirn%=^%Folders^%count%%
        ^!InsertText Directory=^%dirn%^p
        ^!Set %filen%=^$GetFileFirst(^%dirn%;*;name)$
        :StartLoop
        ^!InsertText ^%filen%^p
        ^!Set %filen%=^$GetFileNext$
        ^!IfFileExist ^%filen% StartLoop
        ^!CloseFileFind
        ^!Goto Folder
        :Out
      • Sheri
        Oops, sorry Ray, I found an error in my clip ... Add this line to the bottom of SpecFolders: ^!Set %agfolders%=^%agdrv%^%agfolders% Regards, Sheri Corrected
        Message 3 of 9 , May 3 8:25 AM
          Oops, sorry Ray, I found an error in my clip ...

          Add this line to the bottom of SpecFolders:
          ^!Set %agfolders%=^%agdrv%^%agfolders%

          Regards,
          Sheri

          Corrected version:

          H="SpecFolders"
          ^!Set %agdrv%=^?[(T=D);Browse to Desired Folder]
          ^!Set %agfolders%=^%NL%
          ^!Append %agfolders%=^$GetDosOutput(dir "^%agdrv%" /ad /b)$
          ^!Set %agfolders%=^$StrReplace("^P^P";"^P";"^%agfolders%";No;No)$
          ^!Set %agfolders%=^$StrTrim(^$StrAsciiToAnsi("^%agfolders%")$)$
          ^!Set %agfolders%=^$StrReplace("^P";"^P^%agdrv%";"^%agfolders%";No;No)$
          ^!Set %agfolders%=^%agdrv%^%agfolders%

          H="show files in dir"
          ^!Clip SpecFolders
          ^!SetListDelimiter=^P
          ^!SetArray %Folders%=^%agfolders%
          ^!Set %count%=0
          :Folder
          ^!Inc %count%
          ^!If ^%count%>^%Folders0% Out
          ^!Set %dirn%=^%Folders^%count%%
          ^!InsertText Directory=^%dirn%^p
          ^!Set %filen%=^$GetFileFirst(^%dirn%;*;name)$
          :StartLoop
          ^!InsertText ^%filen%^p
          ^!Set %filen%=^$GetFileNext$
          ^!IfFileExist ^%filen% StartLoop
          ^!CloseFileFind
          ^!Goto Folder
          :Out
        • hsavage
          ... Ray, A short clip to produce a file list in a wizard box. Second clip creates a new doc containing the file list. hrs H= show files in dir ^!Set
          Message 4 of 9 , May 3 8:58 AM
            Ray Tomes wrote:

            >Greetings All
            >
            >I am new to this NoteTabbing and still very much learning my way
            >around. I want to know how to follow a directory tree, that is to find
            >the names of the directories within a directory as well as the files.
            >Below is my simple file list from a directory, how would I change this
            >to show the directories in a selected directory? I could do a DOS
            >"DIR" command to a file and read it back, but I am wondering if there
            >is a more elegant way.
            >
            >BTW, I only have NoteTab Lite, so please keep to functions that work
            >in that.
            >
            >Regards
            >
            >Ray Tomes
            >
            >H="show files in dir"
            >^!Set %dirn%=^?[(T=D)Directory=]
            >^!InsertText Directory=^%dirn%^p
            >^!Set %filen%=^$GetFileFirst(^%dirn%;*;name)$
            >:StartLoop
            >^!InsertText ^%filen%^p
            >^!Set %filen%=^$GetFileNext$
            >^!IfFileExist ^%filen% StartLoop
            >^!CloseFileFind
            >
            Ray,

            A short clip to produce a file list in a wizard box. Second clip
            creates a new doc containing the file list.

            hrs

            H="show files in dir"
            ^!Set %dirn%=^?{(T=D)Directory=^$GetAppPath$}
            ^!SetListDelimiter |
            ^!Set %filen%=^$GetFiles(^%dirn%;*.*;name)$
            ^!Set %filen%="^$StrReplace("^%dirn%";"";"^%filen%";0;0)$"
            ^!Set %list%=^?{(H=32)FILES IN-- ^%dirn% --FOLDER==^%filen%}

            H="show files in dir"
            ^!Set %dirn%=^?{(T=D)Directory=^$GetAppPath$}
            ^!SetListDelimiter ^%nl%
            ^!Set %filen%=^$GetFiles(^%dirn%;*.*;name)$
            ^!Set %filen%="^$StrReplace("^%dirn%";"";"^%filen%";0;0)$"
            ^!Menu File/new
            ^!InsertText FILES IN-- ^%dirn% --FOLDER^%nl%^%filen%
          • Larry Thomas
            Hi Ray, ... This clip will do what you ask from DOS. It does not require you to enter a DIR command. It creates a file in your home folder with the correct
            Message 5 of 9 , May 3 12:29 PM
              Hi Ray,

              At 02:45 AM 5/3/03 -0000, you wrote:
              >Greetings All
              >
              >I am new to this NoteTabbing and still very much learning my way
              >around. I want to know how to follow a directory tree, that is to find
              >the names of the directories within a directory as well as the files.
              >Below is my simple file list from a directory, how would I change this
              >to show the directories in a selected directory? I could do a DOS
              >"DIR" command to a file and read it back, but I am wondering if there
              >is a more elegant way.
              >
              >BTW, I only have NoteTab Lite, so please keep to functions that work
              >in that.
              >

              This clip will do what you ask from DOS. It does not require you to enter
              a DIR command. It creates a file in your home folder with the correct DIR
              command and the required parameters based on how you answer the wizards.
              It creates a file in your home folder called dc.bat and runs it with
              ^$GetOutput("^$GetAppPath$dc.bat")$

              ______[Copy below this line]_______
              H="Folders2Doc"
              ;Larry Thomas <larryt@...>
              ;05/03/2003, 02:15:15 PM
              ;
              ;----------------------[begin long line]---------------------------
              ^!Set %DirName%=^?{Folder to browse from.=_C:\|C:\Program Files\NoteTab
              Light\}
              ;-----------------------[end long line]----------------------------
              ;
              ;
              ;----------------------[begin long line]---------------------------
              ^!Set
              %Folder%=^?{(T=D)Browse=^%DirName%};%SubDir%=^?{Subdirectories?=Yes^=/s|_No^
              =};%Bare%=^?{Bare Format?=_Yes^=/b|No^=}
              ;-----------------------[end long line]----------------------------
              ;
              ^!Set %Options%=@Echo off^%NL%Dir /ad^%SubDir%^%Bare% "^%Folder%"
              ^!TextToFile "^$GetAppPath$dc.bat" ^%Options%^%NL%
              ^!SetClipboard ^$GetOutput("^$GetAppPath$dc.bat")$
              ^!Toolbar Paste New
              _____[Copy above this line]______
              | right click over the clipbook |
              | and choose "Add from Clipboard" |
              ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯

              Regards,

              Larry
              larryt@...
            • Larry Thomas
              Hi Ray, When I set the clip to print a bare folder list with no subdirectories, it does not show the path names for the folders. Furthermore, I would like it
              Message 6 of 9 , May 3 5:43 PM
                Hi Ray,

                When I set the clip to print a bare folder list with no subdirectories, it
                does not show the path names for the folders. Furthermore, I would like it
                to show the parent folder of the list being shown. I have revised the clip
                so that it does this now. Here is the revised clip.

                ______[Copy below this line]_______
                H="Folders2Doc"
                ;Larry Thomas <larryt@...>
                ;05/03/2003, 07:10:20 PM
                ;
                ;----------------------[begin long line]---------------------------
                ^!Set %DirName%=^?{Folder to browse from.=_C:\|C:\Program Files\NoteTab Pro\}
                ;-----------------------[end long line]----------------------------
                ;
                ;
                ;----------------------[begin long line]---------------------------
                ^!Set
                %Folder%=^?{(T=D)Browse=^%DirName%};%SubDir%=^?{Subdirectories?=Yes^=/s|_No^
                =};%Bare%=^?{Bare Format?=_Yes^=/b|No^=}
                ;-----------------------[end long line]----------------------------
                ;
                ^!Set %Options%=@Echo off^%NL%Dir /ad^%SubDir%^%Bare% "^%Folder%"
                ^!TextToFile "^$GetAppPath$dc.bat" ^%Options%^%NL%
                ;
                ;----------------------[begin long line]---------------------------
                ^!SetClipboard
                ^$StrDeleteRight("^%Folder%";1)$^%NL%^$GetOutput("^$GetAppPath$dc.bat")$
                ;-----------------------[end long line]----------------------------
                ;
                ;^!SetClipboard ^$StrDeleteRight("^$GetClipboard$";2)$
                ^!Toolbar Paste New
                ^!Keyboard Backspace
                ^!Jump 1
                ^!If ^$StrPos("Dir /ad/b";"^%Options%";False)$ > 0 Next ELSE Exit
                ;^!Info ^%Folder%
                ^!Replace "^%NL%" >> "^%NL%^%Folder%" TISA
                ^!Jump 1
                _____[Copy above this line]______
                | right click over the clipbook |
                | and choose "Add from Clipboard" |
                ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯

                Regards,

                Larry
                larryt@...
              • Ray Tomes
                ... Yes I thought of that and tried D although it wasn t mentioned in the documentation, but as you say it doesn t work. It seems to me that this would be a
                Message 7 of 9 , May 3 7:19 PM
                  Sheri wrote:
                  >The problem of getting and processing subdirectories is one I've
                  >struggled with before. I also suggested that the ^$GetFiles function
                  >be enhanced to support attribute "D" for directory when specified.
                  >Other normal file attributes work, but "D" doesn't.

                  Yes I thought of that and tried D although it wasn't mentioned in the
                  documentation, but as you say it doesn't work. It seems to me that
                  this would be a good addition to NT as it allows some nice extra
                  things to be done.

                  Sheri, thanks for the comments and the clip.

                  Thanks also to hsavage and Larry for their dir of dir clips.

                  Larry wrote:
                  >When I set the clip to print a bare folder list with no
                  >subdirectories, it does not show the path names for the folders.
                  >Furthermore, I would like it to show the parent folder of the
                  >list being shown.

                  Yes, it is funny but when I did a dir of dir it left out the path as
                  you say, unless I had subdirectories then it put the path in.

                  H="DOS dir"
                  ^!Set %dirn%=^?[(T=D)Directory=]
                  ^$GetDosOutput(dir ^%dirn% /A:D /O:N /B /S)$
                • Larry Thomas
                  Hi Ray, ... First, the clip snippet above is not from my clip that was last posted. I tested it on NoteTab Light and it worked even when no subdirectories
                  Message 8 of 9 , May 4 8:12 AM
                    Hi Ray,

                    At 02:19 AM 5/4/03 -0000, you wrote:
                    >Thanks also to hsavage and Larry for their dir of dir clips.
                    >
                    >Larry wrote:
                    >>When I set the clip to print a bare folder list with no
                    >>subdirectories, it does not show the path names for the folders.
                    >>Furthermore, I would like it to show the parent folder of the
                    >>list being shown.
                    >
                    >Yes, it is funny but when I did a dir of dir it left out the path as
                    >you say, unless I had subdirectories then it put the path in.
                    >
                    >H="DOS dir"
                    >^!Set %dirn%=^?[(T=D)Directory=]
                    >^$GetDosOutput(dir ^%dirn% /A:D /O:N /B /S)$

                    First, the clip snippet above is not from my clip that was last posted. I
                    tested it on NoteTab Light and it worked even when no subdirectories were
                    selected.

                    Here it is again. Try it and see.

                    ______[Copy below this line]_______
                    H="Folders2Doc"
                    ;Larry Thomas <larryt@...>
                    ;05/03/2003, 07:10:20 PM
                    ;
                    ;----------------------[begin long line]---------------------------
                    ^!Set %DirName%=^?{Folder to browse from.=_C:\|C:\Program Files\NoteTab Pro\}
                    ;-----------------------[end long line]----------------------------
                    ;
                    ;
                    ;----------------------[begin long line]---------------------------
                    ^!Set
                    %Folder%=^?{(T=D)Browse=^%DirName%};%SubDir%=^?{Subdirectories?=Yes^=/s|_No^
                    =};%Bare%=^?{Bare Format?=_Yes^=/b|No^=}
                    ;-----------------------[end long line]----------------------------
                    ;
                    ^!Set %Options%=@Echo off^%NL%Dir /ad^%SubDir%^%Bare% "^%Folder%"
                    ^!TextToFile "^$GetAppPath$dc.bat" ^%Options%^%NL%
                    ;
                    ;----------------------[begin long line]---------------------------
                    ^!SetClipboard
                    ^$StrDeleteRight("^%Folder%";1)$^%NL%^$GetOutput("^$GetAppPath$dc.bat")$
                    ;-----------------------[end long line]----------------------------
                    ;
                    ^!Toolbar Paste New
                    ^!Keyboard Backspace
                    ^!Jump 1
                    ^!If ^$StrPos("Dir /ad/b";"^%Options%";False)$ > 0 Next ELSE Exit
                    ^!Replace "^%NL%" >> "^%NL%^%Folder%" TISA
                    ^!Jump 1
                    _____[Copy above this line]______
                    | right click over the clipbook |
                    | and choose "Add from Clipboard" |
                    ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯

                    Regards,

                    Larry
                    larryt@...
                  • Larry Thomas
                    Hi Ray, If you are having trouble adding my clip to your librarie, I have posted it in the form below to avoid problems caused by the email system modifying it
                    Message 9 of 9 , May 4 8:31 AM
                      Hi Ray,

                      If you are having trouble adding my clip to your librarie, I have posted it
                      in the form below to avoid problems caused by the email system modifying it
                      in transit. You can restore the clip below manually by first joining any
                      long lines marked between the long line markers. then you can delete the
                      lines containing:

                      ______[Copy below this line]_______

                      ;
                      ;----------------------[begin long line]---------------------------

                      ;-----------------------[end long line]----------------------------
                      ;

                      and

                      _____[Copy above this line]______
                      | right click over the clipbook |
                      | and choose "Add from Clipboard" |
                      ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯

                      when you have done that you can copy the whole clip to the clipboard and
                      then do what the last box says.
                      "right click over the clipbook and choose "Add from Clipboard" '. Then you
                      can type in the name I gave to the clip or any other you think is better
                      and click ok and it is ready to run.

                      ______[Copy below this line]_______
                      H="Folders2Doc"
                      ;Larry Thomas <larryt@...>
                      ;05/03/2003, 07:10:20 PM
                      ;
                      ;----------------------[begin long line]---------------------------
                      ^!Set %DirName%=^?{Folder to browse from.=_C:\|C:\Program Files\NoteTab Pro\}
                      ;-----------------------[end long line]----------------------------
                      ;
                      ;
                      ;----------------------[begin long line]---------------------------
                      ^!Set
                      %Folder%=^?{(T=D)Browse=^%DirName%};%SubDir%=^?{Subdirectories?=Yes^=/s|_No^
                      =};%Bare%=^?{Bare Format?=_Yes^=/b|No^=}
                      ;-----------------------[end long line]----------------------------
                      ;
                      ^!Set %Options%=@Echo off^%NL%Dir /ad^%SubDir%^%Bare% "^%Folder%"
                      ^!TextToFile "^$GetAppPath$dc.bat" ^%Options%^%NL%
                      ;
                      ;----------------------[begin long line]---------------------------
                      ^!SetClipboard
                      ^$StrDeleteRight("^%Folder%";1)$^%NL%^$GetOutput("^$GetAppPath$dc.bat")$
                      ;-----------------------[end long line]----------------------------
                      ;
                      ^!Toolbar Paste New
                      ^!Keyboard Backspace
                      ^!Jump 1
                      ^!If ^$StrPos("Dir /ad/b";"^%Options%";False)$ > 0 Next ELSE Exit
                      ^!Replace "^%NL%" >> "^%NL%^%Folder%" TISA
                      ^!Jump 1
                      _____[Copy above this line]______
                      | right click over the clipbook |
                      | and choose "Add from Clipboard" |
                      ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯

                      Regards,

                      Larry
                      larryt@...
                    Your message has been successfully submitted and would be delivered to recipients shortly.