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

Re: [Clip] automatic naming of files

Expand Messages
  • hsavage
    ... tux, Have you resolved your requirement for using the first text line for the ^!Save AS Filename to save files to. If you re interested I ve constructed
    Message 1 of 11 , Oct 11, 2005
    • 0 Attachment
      tuxtyro wrote:
      > Greetings from a newcomer to the group and a programmer-wannabe. In
      > the ubiquitous MS Word, when 'Save As' is selcected the beginning text
      > of a file is offered as a suggested file name. What do i substitute
      > for <NoName%0.2d> to get the same result from NoteTab? I've tried
      > different variations on FileName and failed. It's got to be a simple
      > coding thing, but i'm lost. I'm currently trying to teach myself Java
      > and C, but my LAST programming was Fortran and RPG in 1970. Yeah,
      > yeah, no comments, now. {8^)
      > TIA

      tux,

      Have you resolved your requirement for using the first text line for the
      '^!Save AS Filename' to save files to.

      If you're interested I've constructed 2 clips, one uses the entire first
      as the filename, the second uses a user pre-set number of words in the
      first line as the filename.

      Both clips scan the selected filename for forbidden characters
      (characters dos and windows won't allow to be used in filenames and
      foldernames) and replaces those characters with a dash. If the proposed
      filename has no restricted characters it saves the file without
      hesitation.

      Word does it slightly differently, it stops the proposed filename at the
      first incidence of a forbidden character.

      Either clip can be modified to display the rename dialog with the
      appropriate text entered as the potential filename. This allows editing
      before the final save.

      To make either clip most useful you should add whichever to a Personal
      ToolBar so it's readily available without having to find and focus the
      clipbook containing the clip.

      Let me know.

      ºvº
      05.10.11
      hrs > hsavage@...
    • Jefry S
      ... Thanks, but i m still having problems. I m using this clip- H= Save As First Line ;_Modified-Updated~Created ;_20051010_12:21:51p_hsavage@pobox.com ; edit
      Message 2 of 11 , Oct 11, 2005
      • 0 Attachment
        hsavage wrote:

        >tuxtyro wrote:
        > > Greetings from a newcomer to the group and a programmer-wannabe. In
        > > the ubiquitous MS Word, when 'Save As' is selcected the beginning text
        > > of a file is offered as a suggested file name. What do i substitute
        > > for <NoName%0.2d> to get the same result from NoteTab? I've tried
        > > different variations on FileName and failed. It's got to be a simple
        > > coding thing, but i'm lost. I'm currently trying to teach myself Java
        > > and C, but my LAST programming was Fortran and RPG in 1970. Yeah,
        > > yeah, no comments, now. {8^)
        > > TIA
        >
        >tux,
        >
        >Have you resolved your requirement for using the first text line for the
        >'^!Save AS Filename' to save files to.
        >
        >If you're interested I've constructed 2 clips, one uses the entire first
        >as the filename, the second uses a user pre-set number of words in the
        >first line as the filename.
        >
        >Both clips scan the selected filename for forbidden characters
        >(characters dos and windows won't allow to be used in filenames and
        >foldernames) and replaces those characters with a dash. If the proposed
        >filename has no restricted characters it saves the file without
        >hesitation.
        >
        >Word does it slightly differently, it stops the proposed filename at the
        >first incidence of a forbidden character.
        >
        >Either clip can be modified to display the rename dialog with the
        >appropriate text entered as the potential filename. This allows editing
        >before the final save.
        >
        >To make either clip most useful you should add whichever to a Personal
        >ToolBar so it's readily available without having to find and focus the
        >clipbook containing the clip.
        >
        >Let me know.
        >
        >ºvº
        >05.10.11
        >hrs > hsavage@...
        >
        >
        >
        >
        >
        >
        >
        >
        Thanks, but i'm still having problems. I'm using this clip-

        H="Save As First Line"
        ;_Modified-Updated~Created
        ;_20051010_12:21:51p_hsavage@...
        ; edit next line to reflect your starting_folder' preference
        ^!Set %path%=^?{(T=D)Choose Path To Save Files=D:\My Documents\NoteTab\}
        ^!Set %line1%=^$GetLine(1)$
        ^!Save AS "^%path%^%line1%.txt"

        when i leave H= intact, i get an error message of-
        Cannot create file D:\My Documents\NoteTab\four score and seven years
        agoH="Save AsFirst Line" - it inserts the H= line at the end of the line
        a semicolon to stop the line gives the desired result and parks the file
        in \NoteTab\
        I'll remove Notetab and put it in My Docs. That still doesn't quite give
        me the option of selecting location to save, like Word does, but it's
        closer. Thanks, i'll have to continue to explore and experiment to get
        the desired result. Any clue as to how to prompt for input to choose
        location?
        Thanks again, this is fun!

        --
        Sincerely,
        Jefry


        The most important thing to remember in Chemistry is, 'don't lick the spoon'.
      • hsavage
        ... That still doesn t quite give ... Jefry, The short clip above was my first attempt, it didn t take into account the presence of some of those forbidden
        Message 3 of 11 , Oct 11, 2005
        • 0 Attachment
          Jefry S wrote:
          > hsavage wrote:
          >>
          > Thanks, but i'm still having problems. I'm using this clip-
          >
          > H="Save As First Line"
          > ;_Modified-Updated~Created
          > ;_20051010_12:21:51p_hsavage@...
          > ; edit next line to reflect your starting_folder' preference
          > ^!Set %path%=^?{(T=D)Choose Path To Save Files=D:\My Documents\NoteTab\}
          > ^!Set %line1%=^$GetLine(1)$
          > ^!Save AS "^%path%^%line1%.txt"
          >
          > when i leave H= intact, i get an error message of-
          > Cannot create file D:\My Documents\NoteTab\four score and seven years
          > agoH="Save AsFirst Line" - it inserts the H= line at the end of the line
          > a semicolon to stop the line gives the desired result and parks the file
          > in \NoteTab\
          > I'll remove Notetab and put it in My Docs.

          That still doesn't quite give
          > me the option of selecting location to save, like Word does, but it's
          > closer. Thanks, i'll have to continue to explore and experiment to get
          > the desired result. Any clue as to how to prompt for input to choose
          > location?
          > Thanks again, this is fun!

          Jefry,

          The short clip above was my first attempt, it didn't take into account
          the presence of some of those forbidden characters I speak of. Double
          quotes are forbidden in folder/filenames. That may be the reason you
          can't save that file.

          I'm not sure what text file you're trying to save, I don't understand
          how you're getting the clip title as the first. Did you just create a
          new file using the clip text as the body of the file?

          With this latest clip it shouldn't matter if you use the clip text, it
          will replace the forbidden characters during operation.

          The process;

          The first dialog lets you choose the destination folder, it must be a
          present folder. After selecting the destination, click OK

          The clip runs, grabs line 1, scans it for forbidden characters replacing
          them with dashes. You can edit that line to use a character other than
          dashes if you wish.

          Edit, if you wish, the ^$StrReplace( line, replace the dash with an
          ascii character of your choosing.

          When the line is prepared for use the ^!KeyBoard F2 line should open the
          Rename Document dialog box, the remainder of the keyboard line inserts
          the revised filename only into the dialog for editing or accepting.

          After this, when you click OK, the filename in the edit window, and, the
          original disk file (if you loaded it from disk) are both renamed.

          If you loaded the file from a source different than the destination you
          chose in the first dialog you will have 2 copies of the file with the
          new filename, one in the source folder and one in the destination folder.

          The last line in the clip, the '^!Save AS' line, is there to insure the
          file will be saved with its new filename in the proper destination
          folder that you chose in the first dialog.

          The proper operation is dependant on whether the destination folder
          exists and whether you get a 'Rename Document' dialog by pressing F2 in
          the NoteTab edit window. F2 should be the NoteTab default to 'Rename
          Document'.

          Try it, reply after testing.

          You should delete the first clip, the one you sent in your email and
          place the one below into your clipbook.

          ------------------
          H="Save As First Line"
          ;_Modified-Updated~Created
          ;_20051011_5:15:18p_hsavage@...
          ^!ClearVariables
          ; edit next line to reflect your starting_folder' preference
          ^!Set %path%=^?{(T=D)Choose Path To Save Files=C:\+r2rweb\lists\}
          ;
          ^!SetListDelimiter ;
          ; these are the 9 forbidden characters I know about, \/:*?"<>|
          ^!SetArray %frbdn%="\;/;:;*;?;";<;>;|"
          ^!Set %idx%=0; %cnt%=^%frbdn0%
          ^!Set %name%="^$GetLine(1)$"
          :FRBDN
          ^!Inc %idx%
          ; replaces forbidden characters with dashes
          ^!Set %name%=^$StrReplace("^%frbdn^%idx%%";"-";"^%name%";0;0)$
          ^!If ^%idx% = ^%cnt% NEXT ELSE FRBDN
          ^!Set %name%=^$StrTrim("^%name%")$
          ;
          ^!KeyBoard F2 &50 #^%name%.#
          ;^!RenameDoc "^%name%"
          ^!Save AS "^%path%^%name%."
          -------------------------

          ºvº
          05.10.11
          hrs > hsavage@...
        • Don Daugherty
          ... I think there is some confusion regarding the H= Save As First Line . That is the clip header-line within a clip library document. If you open any clip
          Message 4 of 11 , Oct 13, 2005
          • 0 Attachment
            hsavage wrote:

            >Jefry S wrote:
            > > hsavage wrote:
            > >>
            > > Thanks, but i'm still having problems. I'm using this clip-
            > >
            > > H="Save As First Line"
            > > ;_Modified-Updated~Created
            > > ;_20051010_12:21:51p_hsavage@...
            > > ; edit next line to reflect your starting_folder' preference
            > > ^!Set %path%=^?{(T=D)Choose Path To Save Files=D:\My Documents\NoteTab\}
            > > ^!Set %line1%=^$GetLine(1)$
            > > ^!Save AS "^%path%^%line1%.txt"
            >
            >
            I think there is some confusion regarding the H="Save As First Line".

            That is the clip header-line within a clip library document. If you
            open any clip library as a text file, either from the File>Open menu
            item, or by right clicking on the library name in the clipbook window
            and choosing Open as document, you will see lines of this nature
            starting each clip. For example, one of my libraries, when so-opened reads

            = V5 MultiLine NoSorting TabWidth=30

            H="Save AS"
            ^!SetDebug On
            ;Above line only for debugging purposes; delete it or prefix it with
            semicolon for normal use.
            ^!Jump Text_Start
            ^!Jump Line_End
            ^!SelectTo 1:1
            ^!Set %FileName%="c:\My Documents\^$GetSelection$."
            ;Above provides nul file extension; use
            ;^!Set %FileName%="c:\My Documents\^$GetSelection$.txt"
            ;if .txt is desired.
            ^!Save AS "^%FileName%"
            ;If preferred, the ^!Set and ^!Save AS lines can be combined into one:
            ;^!Save AS "c:\My Documents\^$GetSelection$." or
            ;^!Save AS "c:\My Documents\^$GetSelection$.txt"

            H="_OpenOrFocusApp"
            ^!CmdShow Maximize
            ^!IfAppOpen "^%TBar%" ^!Clip "AlreadyInUse"

            One way to get the new clip into a library is to open that library in
            this manner, and pasting the above text into an appropriate spot in that
            document. "An appropriate spot" would be above an existing H="blah,
            blah, " line. Be sure that each H="..." line has a blank line before
            and after it, as illustrated above.)

            The more usual way of entering clips into an existing library, is to
            simply make the library the active or Open one in the clip library,
            right click over any clipname listed within that library, and choosing
            Add New Clip... This will prompt you to supply a name for the new clip
            ("Save As 1st Line"?).
            Once you have done that, a new main window will be opened and you can
            start typing-in commands or pasting-in commands copied from email. In
            that case your copying should EXCLUDE the H="Save ..." line in the email.
          • hsavage
            ... Jefry, The clip above was my second completed attempt, it is the one you may be using now. I have a new, modified version I m going to paste below. It s
            Message 5 of 11 , Oct 13, 2005
            • 0 Attachment
              hsavage wrote:
              > Jefry S wrote:
              >> hsavage wrote:
              >>>
              >> Thanks, but i'm still having problems. I'm using this clip-
              >
              > Any clue as to how to prompt for input to choose location?
              >
              > Thanks again, this is fun!
              >
              > ------------------
              > H="Save As First Line"
              > ;_Modified-Updated~Created
              > ;_20051011_5:15:18p_hsavage@...
              > ^!ClearVariables
              > ; edit next line to reflect your starting_folder' preference
              > ^!Set %path%=^?{(T=D)Choose Path To Save Files=C:\+r2rweb\lists\}
              > ;
              > ^!SetListDelimiter ;
              > ; these are the 9 forbidden characters I know about, \/:*?"<>|
              > ^!SetArray %frbdn%="\;/;:;*;?;";<;>;|"
              > ^!Set %idx%=0; %cnt%=^%frbdn0%
              > ^!Set %name%="^$GetLine(1)$"
              > :FRBDN
              > ^!Inc %idx%
              > ; replaces forbidden characters with dashes
              > ^!Set %name%=^$StrReplace("^%frbdn^%idx%%";"-";"^%name%";0;0)$
              > ^!If ^%idx% = ^%cnt% NEXT ELSE FRBDN
              > ^!Set %name%=^$StrTrim("^%name%")$
              > ;
              > ^!KeyBoard F2 &50 #^%name%.#
              > ;^!RenameDoc "^%name%"
              > ^!Save AS "^%path%^%name%."
              > -------------------------

              Jefry,

              The clip above was my second completed attempt, it is the one you may be
              using now. I have a new, modified version I'm going to paste below.
              It's my favorite so far. I like it well enough that I added an icon for
              it in 2 of my Personal Toolbars.

              The clip runs, grabs line 1, scans it for forbidden characters replacing
              them with dashes. You can edit that line to use a character other than
              dashes if you wish.

              Edit, if you wish, the ^$StrReplace( line, replace the dash with an
              ascii character of your choosing.

              This is different from previous clips in that it uses only ONE Wizard
              which allows 3 inputs,

              input 1. an entry point to edit the proposed filename.

              input 2. select default save location or use the wizard to select a new
              location.

              input 3. allow choice of whether to retain or delete source file.
              Default is to retain, not delete, source.

              ----------------------------
              H="Save As First Line"
              ;_Modified-Updated~Created
              ;_20051013_2:07:17p_hsavage@...
              ^!ClearVariables
              ^!Set %sourcefile%="^$GetExpandedName(^##)$"
              ^!SetListDelimiter ;
              ;
              ; these are the 9 forbidden characters I know about, \/:*?"<>|
              ^!SetArray %frbdn%="\;/;:;*;?;";<;>;|"
              ^!Set %idx%=0; %cnt%=^%frbdn0%
              ^!Set %name%="^$GetLine(1)$"
              :FRBDN
              ^!Inc %idx%
              ; replaces forbidden characters with dashes
              ^!Set %name%=^$StrReplace("^%frbdn^%idx%%";"-";"^%name%";0;0)$
              ^!If ^%idx% = ^%cnt% NEXT ELSE FRBDN
              ^!Set %name%=^$StrTrim("^%name%")$
              ; edit next line to reflect your starting_folder' preference
              ;
              ^!SetWizardLabel "Choose Destination - Edit FileName - Delete SourceFile"
              ;
              ; this is a very long line, you should check to make sure it is
              straightened out
              ^!Set %name%=^?{New FileName to Accept or Edit=^%name%};
              %path%=^?{(T=D)Choose Destination Path For File=C:\+r2rweb\lists\};
              %delsource%=^?{Delete Source_File==Yes^=1|_No^=0}
              ;
              ^!Save AS "^%path%^%name%"
              ^!IfTrue ^%delsource% ^!DeleteFile ^%sourcefile%
              ---------------------------------------

              Long lines usually get wrapped in email and it's up to you to make a
              single long line out of them again. I've separated the most likely to
              be wrapped with blank lines.

              Try this clip, I think you'll like it better than the last.

              ºvº
              05.10.13
              hrs > hsavage@...
            • Bob McAllister
              ... section of the text. ^!Set %TempVar%=^$GetSelection$ ^!RenameDoc ^%TempVar%.txt but I have been prompted to borrow some of the excellent ideas in
              Message 6 of 11 , Oct 16, 2005
              • 0 Attachment
                On 10/14/05, hsavage <hsavage@...> wrote:
                >
                > Try this clip, I think you'll like it better than the last.
                >
                > ºvº
                > 05.10.13
                > hrs > hsavage@...
                >
                >
                > I had been using a very simple clip to rename a file using a selected
                section of the text.
                ^!Set %TempVar%=^$GetSelection$
                ^!RenameDoc ^%TempVar%.txt
                but I have been prompted to "borrow" some of the excellent ideas in
                hsavage's work to build the following that will use selected text (if there
                is any) or the first line of the file as the basis for the filename.
                As well as stripping out the illegal characters, the clip will (i) limit
                the filename to a predetermined length (ii) check that there is no space
                immediately before the file extension (.txt) or (iii) remove all spaces
                within the filename. Activate any or all of these to suit your personal
                preferences.
                H="Name as selection or first line"
                ^!ClearVariables
                ^!Set %namelength%=10
                ^!Set %sourcefile%="^$GetExpandedName(^##)$"
                ;
                ^!Set %NewName%="^$GetLine(1)$"
                ^!If ^$GetSelSize$ = 0 Skip_1
                ^!Set %NewName%=^$GetSelection$
                ;
                ^!SetListDelimiter ;
                ^!SetArray %frbdn%="\;/;:;*;?;";<;>;|"
                ^!Set %idx%=0; %cnt%=^%frbdn0%
                :FRBDN
                ^!Inc %idx%
                ^!Set %NewName%=^$StrReplace("^%frbdn^%idx%%";"-";"^%NewName%";0;0)$
                ^!If ^%idx% = ^%cnt% NEXT ELSE FRBDN
                ;
                ;To limit name to specified maximum length
                ;remove semicolon at start of next line.
                ;^!Set %NewName%=^$StrCopy("^%NewName%";1;^%namelength%)$
                ;To prevent name ending with a space
                ;remove semicolon at start of next line.
                ;^!Set %NewName%=^$StrTrim("^%NewName%")$
                ;To strip all spaces from within name
                ;remove semicolon at start of next line.
                ;^!Set %NewName%=^$StrReplace(" ";"";"^%NewName%";0;0)$
                ;
                ^!SetWizardLabel "Confirm name, directory and backup"
                ;---------Long line follows------------------
                ^!Set %name%=^?{New FileName to Accept or Edit=^%NewName%.txt};
                %path%=^?{(T=D)Choose Destination Path For File=d:\rjmca0\};
                %delsource%=^?{Keep original (if it exists)==No^=1|_Yes^=0}
                ;-----------End of long line---------------
                ^!Save AS "^%path%^%name%"
                ^!IfTrue ^%delsource% ^!DeleteFile ^%sourcefile%
                Bob McAllister


                [Non-text portions of this message have been removed]
              • rpdooling
                Dear hrs: That last clip is a keeper. Thanks rpd ... may be ... for ... new ... SourceFile
                Message 7 of 11 , Oct 17, 2005
                • 0 Attachment
                  Dear hrs:

                  That last clip is a keeper. Thanks

                  rpd

                  --- In ntb-clips@yahoogroups.com, hsavage <hsavage@p...> wrote:
                  >
                  > hsavage wrote:
                  > > Jefry S wrote:
                  > >> hsavage wrote:
                  > >>>
                  > >> Thanks, but i'm still having problems. I'm using this clip-
                  > >
                  > > Any clue as to how to prompt for input to choose location?
                  > >
                  > > Thanks again, this is fun!
                  > >
                  > > ------------------
                  > > H="Save As First Line"
                  > > ;_Modified-Updated~Created
                  > > ;_20051011_5:15:18p_hsavage@p...
                  > > ^!ClearVariables
                  > > ; edit next line to reflect your starting_folder' preference
                  > > ^!Set %path%=^?{(T=D)Choose Path To Save Files=C:\+r2rweb\lists\}
                  > > ;
                  > > ^!SetListDelimiter ;
                  > > ; these are the 9 forbidden characters I know about, \/:*?"<>|
                  > > ^!SetArray %frbdn%="\;/;:;*;?;";<;>;|"
                  > > ^!Set %idx%=0; %cnt%=^%frbdn0%
                  > > ^!Set %name%="^$GetLine(1)$"
                  > > :FRBDN
                  > > ^!Inc %idx%
                  > > ; replaces forbidden characters with dashes
                  > > ^!Set %name%=^$StrReplace("^%frbdn^%idx%%";"-";"^%name%";0;0)$
                  > > ^!If ^%idx% = ^%cnt% NEXT ELSE FRBDN
                  > > ^!Set %name%=^$StrTrim("^%name%")$
                  > > ;
                  > > ^!KeyBoard F2 &50 #^%name%.#
                  > > ;^!RenameDoc "^%name%"
                  > > ^!Save AS "^%path%^%name%."
                  > > -------------------------
                  >
                  > Jefry,
                  >
                  > The clip above was my second completed attempt, it is the one you
                  may be
                  > using now. I have a new, modified version I'm going to paste below.
                  > It's my favorite so far. I like it well enough that I added an icon
                  for
                  > it in 2 of my Personal Toolbars.
                  >
                  > The clip runs, grabs line 1, scans it for forbidden characters replacing
                  > them with dashes. You can edit that line to use a character other than
                  > dashes if you wish.
                  >
                  > Edit, if you wish, the ^$StrReplace( line, replace the dash with an
                  > ascii character of your choosing.
                  >
                  > This is different from previous clips in that it uses only ONE Wizard
                  > which allows 3 inputs,
                  >
                  > input 1. an entry point to edit the proposed filename.
                  >
                  > input 2. select default save location or use the wizard to select a
                  new
                  > location.
                  >
                  > input 3. allow choice of whether to retain or delete source file.
                  > Default is to retain, not delete, source.
                  >
                  > ----------------------------
                  > H="Save As First Line"
                  > ;_Modified-Updated~Created
                  > ;_20051013_2:07:17p_hsavage@p...
                  > ^!ClearVariables
                  > ^!Set %sourcefile%="^$GetExpandedName(^##)$"
                  > ^!SetListDelimiter ;
                  > ;
                  > ; these are the 9 forbidden characters I know about, \/:*?"<>|
                  > ^!SetArray %frbdn%="\;/;:;*;?;";<;>;|"
                  > ^!Set %idx%=0; %cnt%=^%frbdn0%
                  > ^!Set %name%="^$GetLine(1)$"
                  > :FRBDN
                  > ^!Inc %idx%
                  > ; replaces forbidden characters with dashes
                  > ^!Set %name%=^$StrReplace("^%frbdn^%idx%%";"-";"^%name%";0;0)$
                  > ^!If ^%idx% = ^%cnt% NEXT ELSE FRBDN
                  > ^!Set %name%=^$StrTrim("^%name%")$
                  > ; edit next line to reflect your starting_folder' preference
                  > ;
                  > ^!SetWizardLabel "Choose Destination - Edit FileName - Delete
                  SourceFile"
                  > ;
                  > ; this is a very long line, you should check to make sure it is
                  > straightened out
                  > ^!Set %name%=^?{New FileName to Accept or Edit=^%name%};
                  > %path%=^?{(T=D)Choose Destination Path For File=C:\+r2rweb\lists\};
                  > %delsource%=^?{Delete Source_File==Yes^=1|_No^=0}
                  > ;
                  > ^!Save AS "^%path%^%name%"
                  > ^!IfTrue ^%delsource% ^!DeleteFile ^%sourcefile%
                  > ---------------------------------------
                  >
                  > Long lines usually get wrapped in email and it's up to you to make a
                  > single long line out of them again. I've separated the most likely to
                  > be wrapped with blank lines.
                  >
                  > Try this clip, I think you'll like it better than the last.
                  >
                  > ºvº
                  > 05.10.13
                  > hrs > hsavage@p...
                  >
                Your message has been successfully submitted and would be delivered to recipients shortly.