First line as file name?

First line as file name?

2
NewbieNewbie
2

    Oct 13, 2006#1

    Hi....

    If the first line of a text file is Growing Oranges is there a way for UltraEdit to automatically save it that way when saving the text file without having to type in the name when the Save dialog pops up?

    :D

    344
    MasterMaster
    344

      Oct 13, 2006#2

      hi,

      save where to ? always the same directory ? What about file-extension ?

      Here is a simple macro-example to save your file to "c:\temp\growing orange" without extension:

      Code: Select all

      InsertMode
      ColumnModeOff
      HexOff
      Top
      Clipboard 9
      Key HOME
      StartSelect
      Key END
      Copy 
      SaveAs "c:\temp\^c"
      ClearClipboard
      Clipboard 0
      hth, Bego

      P.S.: see also there: Default file type or file extension for new files
      Normally using all newest english version incl. each hotfix. Win 10 64 bit

      6,675585
      Grand MasterGrand Master
      6,675585

        Oct 13, 2006#3

        No!

        And I really hate this MS Word mechanism because it produces many files with not really useful file names which make problems later, although the mechanism itself is not the problem. The real problem are the users who are too lazy to type in a decent file name (without spaces) because they are not forced to enter a decent file name.

        Well, you can use an automatically loaded macro with an appropriate hotkey assignment to save new files with the first line as file name. An example macro code for this job:

        IfNameIs ""
        InsertMode
        ColumnModeOff
        HexOff
        Top
        Key END
        IfColNumGt 1
        ".txt"
        Clipboard 9
        StartSelect
        Key HOME
        Copy
        EndSelect
        Key END
        Key BACKSPACE
        Key BACKSPACE
        Key BACKSPACE
        Key BACKSPACE
        SaveAs "^c"
        ClearClipboard
        Clipboard 0
        Else
        SaveAs ""
        EndIf
        EndIf

        It has some disadvantages:

        The cursor is at end of the first line after execution. So you must use "Go to last position" to bring the cursor back to the position before save.

        The file extension is fixed and you cannot modify the path. It will always save the file with the extension in the macro to current working directory whatever the current working directory is.

        And it's not possible to change the line terminator or the file format before save as it is possible with the Save As command.

        It's not possible to open the Save As dialog with the copied first line pasted into the File Name field.

        Well, you can modify the macro above to copy the first line to windows clipboard (Clipboard 0) and just open the Save As dialog (SaveAs "") and you manually press Ctrl+V to insert the "file name".

        Hi Bego!

        I have seen your post after submitting my post. Your macro will not work for files where first line is an empty line.
        Best regards from an UC/UE/UES for Windows user from Austria

        2
        NewbieNewbie
        2

          Oct 13, 2006#4

          Save with a text extension, same directory every time.

          :D

          Thanks for the tips on macros!

          344
          MasterMaster
          344

            Oct 13, 2006#5

            Hi Mofi, auch noch wach oder was ?
            Your macro will not work for files where first line is an empty line.
            Right. But I don't think this is really important.

            rds Bego
            Normally using all newest english version incl. each hotfix. Win 10 64 bit