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

Re: [Clip] First line of text to file name??

Expand Messages
  • flo.gehrke
    ... John, Here s another idea. Enter the line... jo hn-sho?t:sky.txt and select it. Now start the following clip and see how NT will replace illegal characters
    Message 1 of 6 , Dec 4, 2010
    • 0 Attachment
      --- In ntb-clips@yahoogroups.com, "John Shotsky" <jshotsky@...> wrote:
      >
      > I have a clip to do that...Mine simply changes all such characters
      > to underscores. My code is not elegant, but it works, and
      > is seldom used. Improvements welcomed.
      >
      > ^!IfFalse ^$IsAltKeyDown$ RUN
      > ^!Info [L]This clip saves a file using the first line of text as a file name. ^PIllegal file name characters are removed
      > from a copy of the first line.^PThe document is saved to NoteTab's default 'new document' folder.
      > ^!GoTo End
      > :RUN
      > ^!Jump Doc_Start
      > ^!Replace "\A\R*(..+)\R" >> "$1\r\n$1\r\n" HRS
      > ^!Jump Doc_Start
      > ^!Select Line
      > ^!Replace "^(.+)[\/\?\<\>\\\:\*\|\"](.+)\R" >> "$1_$2\r\n" HRS0
      > ^!IfError Next Else Skip_-3
      > ^!Jump Doc_Start
      > ^!Select Line
      > ^!Set %RenameDoc%=^$GetLine$
      > ^!Save as ^%RenameDoc%.txt
      > ^!Jump Doc_Start
      > ^!Replace "^(..+)\R" >> "" HRS
      > ^!Save
      > :End


      John,

      Here's another idea. Enter the line...

      jo\hn-sho?t:sky.txt

      and select it. Now start the following clip and see how NT will replace illegal characters with underscores:


      ^!Set %Name%=^$GetSelection$
      ^!Set %Position%=1

      :Loop
      ^!Set %Proof%=^$StrCopy(^%Name%;^%Position%;1)$
      ^!IfMatch "[:\\\/\$\?]" "^%Proof%" Next Else Skip
      ^!Set %Proof%=^$StrReplace("^%Proof%";"_";^%Proof%;0;0)$
      ^!Append %CorrectName%=^%Proof%
      ^!Inc %Position%
      ^!If ^%Position% > ^$StrSize(^%Name%)$ Out
      ^!Goto Loop

      :Out
      ^!Info The correct name is ^%CorrectName%
      ^!ClearVariable %CorrectName%

      Maybe you'll have to add somemore illegal characters. This could easily be combined with the rest of the clip that saves the file...

      Regards,
      Flo
    • John Shotsky
      Thanks Flo! Yes, I can adapt that to my users needs. Regards, John http://recipetoolz.com From: ntb-clips@yahoogroups.com
      Message 2 of 6 , Dec 4, 2010
      • 0 Attachment
        Thanks Flo!
        Yes, I can adapt that to my users' needs.

        Regards,
        John
        <http://recipetoolz.com/> http://recipetoolz.com

        From: ntb-clips@yahoogroups.com [mailto:ntb-clips@yahoogroups.com] On Behalf Of flo.gehrke
        Sent: Saturday, December 04, 2010 8:24 AM
        To: ntb-clips@yahoogroups.com
        Subject: Re: [Clip] First line of text to file name??


        --- In ntb-clips@yahoogroups.com <mailto:ntb-clips%40yahoogroups.com> , "John Shotsky" <jshotsky@...> wrote:
        >
        > I have a clip to do that...Mine simply changes all such characters
        > to underscores. My code is not elegant, but it works, and
        > is seldom used. Improvements welcomed.
        >
        > ^!IfFalse ^$IsAltKeyDown$ RUN
        > ^!Info [L]This clip saves a file using the first line of text as a file name. ^PIllegal file name characters are
        removed
        > from a copy of the first line.^PThe document is saved to NoteTab's default 'new document' folder.
        > ^!GoTo End
        > :RUN
        > ^!Jump Doc_Start
        > ^!Replace "\A\R*(..+)\R" >> "$1\r\n$1\r\n" HRS
        > ^!Jump Doc_Start
        > ^!Select Line
        > ^!Replace "^(.+)[\/\?\<\>\\\:\*\|\ <file:///\\\:\*\|\%22%5d(.+)\R> "](.+)\R" >> "$1_$2\r\n" HRS0
        > ^!IfError Next Else Skip_-3
        > ^!Jump Doc_Start
        > ^!Select Line
        > ^!Set %RenameDoc%=^$GetLine$
        > ^!Save as ^%RenameDoc%.txt
        > ^!Jump Doc_Start
        > ^!Replace "^(..+)\R" >> "" HRS
        > ^!Save
        > :End

        John,

        Here's another idea. Enter the line...

        jo\hn-sho?t:sky.txt

        and select it. Now start the following clip and see how NT will replace illegal characters with underscores:

        ^!Set %Name%=^$GetSelection$
        ^!Set %Position%=1

        :Loop
        ^!Set %Proof%=^$StrCopy(^%Name%;^%Position%;1)$
        ^!IfMatch "[:\\\/\$\?]" "^%Proof%" Next Else Skip
        ^!Set %Proof%=^$StrReplace("^%Proof%";"_";^%Proof%;0;0)$
        ^!Append %CorrectName%=^%Proof%
        ^!Inc %Position%
        ^!If ^%Position% > ^$StrSize(^%Name%)$ Out
        ^!Goto Loop

        :Out
        ^!Info The correct name is ^%CorrectName%
        ^!ClearVariable %CorrectName%

        Maybe you'll have to add somemore illegal characters. This could easily be combined with the rest of the clip that saves
        the file...

        Regards,
        Flo



        [Non-text portions of this message have been removed]
      Your message has been successfully submitted and would be delivered to recipients shortly.