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

14339Re: [Clip] automatic naming of files

Expand Messages
  • Bob McAllister
    Oct 16, 2005
      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
      H="Name as selection or first line"
      ^!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%
      ^!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]
    • Show all 11 messages in this topic