Find backwards and copy last directory name to clipboard

Find backwards and copy last directory name to clipboard

9
NewbieNewbie
9

    Nov 26, 2006#1

    Hi, I'm using Ultraedit to write Robocopy batch scripts. I start my batch files pasting a list of directories (that I copy on my file manager) as :

    C:\Windows
    C:\Program Files\Opera

    Macro should copy the name of present directory or subdirectory to clipboard :

    Code: Select all

    C:\Windows               macro must copy to clipboard "Windows"
    C:\Program Files\Opera   macro must copy to clipboard "Opera"
    The problem that I've found is that I don't know how to configure my macro to find backward for "\" to be able to use :

    Code: Select all

    Key END
    Find BACKWARD "\"            <-- PROBLEM
    Key LEFT ARROW
    Key RIGHT ARROW
    StartSelect
    Key END
    Copy 
    EndSelect
    Key DOWN ARROW
    May you help me ? , thanks.

    6,606548
    Grand MasterGrand Master
    6,606548

      Nov 26, 2006#2

      Find backwards means find upwards:

      Key END
      Find Up "\"
      Key LEFT ARROW
      Key RIGHT ARROW
      StartSelect
      Key END
      Copy
      EndSelect
      Key DOWN ARROW

      If you already have a file with a list of directory names it is much faster to convert them with a regular expression search and replace.

      The following macro
      • copies the content of the current file (list of directories) to a new ASCII file with DOS line terminations,
      • adds also a DOS line termination at the end of the file if the last line has not already a line termination,
      • removes trailing spaces (for security),
      • deletes everything before last backslash at every line and
      • copies the rest back to current clipboard before discarding the new temp file.
      Well, you can modify the replace string to get the line you need in the batch file with a single search and replace all.

      InsertMode
      ColumnModeOff
      HexOff
      UnixReOff
      SelectAll
      Copy
      NewFile
      UnicodeToASCII
      UnixMacToDos
      Paste
      IfColNum 1
      Else
      "
      "
      EndIf
      Top
      TrimTrailingSpaces
      Find RegExp "%*\^([~\^p]+^)$"
      Replace All "^1"
      SelectAll
      Copy
      CloseFile NoSave

      Add UnixReOn or PerlReOn (v12+ of UE) at the end of the macro if you do not use UltraEdit style regular expressions by default - see search configuration. Macro command UnixReOff sets the regular expression option to UltraEdit style.
      Best regards from an UC/UE/UES for Windows user from Austria

      9
      NewbieNewbie
      9

        Nov 27, 2006#3

        Thanks :!: