open from FTP - getting true filename into clipboard.

open from FTP - getting true filename into clipboard.

21
Basic UserBasic User
21

    Apr 09, 2009#1

    The command "CopyFilePath" is great for local/network files.
    However for FTP opened files, the string returned is not a "real" name that one can use at a OS prompt.
    The string received is a special UE format of:
    FTP::{yourftpaccount}\/path/path/path|filename.ext

    Basically two search replace commands can convert the above into the true/correct filename.
    1) remove everything between the "FTP::" and the "\" (backslash)
    2) convert the vertical bar to a slash.

    The following macro is somewhat functional but not perfect because it uses a temp file
    the macrow as written may, (or may not), return you to the correct tab/edit point from which you came.

    My questions are:
    If I could find/replace within a clipboard I would have neither issue.
    Is this possible?
    Am I re-inventing the wheel here - does anyone have a better way?

    Code: Select all

    InsertMode
    ColumnModeOn
    HexOff
    Clipboard 6
    CopyFilePath
    NewFile
    Paste
    Clipboard 0
    UltraEditReOn
    Find RegExp "FTP::*\"
    Replace All ""
    UltraEditReOn
    Find "|"
    Replace All "/"
    Key HOME
    Key SHIFT
    StartSelect
    Key END
    EndSelect
    Cut
    CloseFile NoSave
    

    61
    Advanced UserAdvanced User
    61

      Apr 10, 2009#2

      I was suprised by the copy filenamespaths not returning the correct path. I always edit them like, you. Seems like a simple fix for UE.

      6,686585
      Grand MasterGrand Master
      6,686585

        Apr 10, 2009#3

        oracledba wrote:Does anyone have a better way?
        I would do that with a script instead of a macro because within the script environment you can copy the name of the active file directly from the document array into a string variable, reformat it with a regular expression and copy the reformatted file name from the string variable into the clipboard. Assign the hotkey normally used for executing Edit - Copy File Path/Name to the script and you are done. Your script should copy local file names or unsaved file names as is into the clipboard, in other words everything not starting with FTP:: is simply copied from the string variable into the clipboard.
        Best regards from an UC/UE/UES for Windows user from Austria

        21
        Basic UserBasic User
        21

          Apr 13, 2009#4

          Mofi - I did not understand the power of scripting and have completely ignored the fact that UE has this ability.
          Thank you for pointing out that UE scripting exists.
          WOW! What was I thinking - scripting is great! Thanks again for pointing this out.

          The following code is my first attempt at scripting.
          It is simple but seemingly effective.

          If anyone wants it - Enjoy.

          Code: Select all

          // my_copyFilePath.js
          
          /* This script exists because the ultraedit function "copyFilePath"
             returns the filename being edited in UE syntax not a native OS syntax.
             For local/network files the two are the same thing however for FTP opened files
             the UE syntax is unique and unusable from the native OS perspective.
          
             This JS script performs several search/replace commands converting the
             string returned into a string recognizable by the native OS.
             Its worth noting that the replace commands do not alter the clipboard contents
             when the string is NOT a ftp opened file. In other words - for local/network 
             files this script will simply leave the clipboard populated with the 
             correct copyFilePath value as returned from UE's copyFilePath function.
          
             The UE syntax for ftp files is:
                   "FTP::[ue-ftp-accountname]\/path/path/path|name.ext"
             to convert into native OS
              step 1) remove the "FTP::[ue-ftp-accountname]\"
              step 2) convert a the vertical bar to a slash.
          
             date       Name            Desc
             4/13/2009  xxxxxxxxx       Initial version
          
           */
          UltraEdit.activeDocument.copyFilePath();
          var clip = UltraEdit.clipboardContent;
          clip = clip.replace(/^FTP::.*\\/, "");
          clip = clip.replace(/\|/, "/");
          UltraEdit.clipboardContent = clip;

          61
          Advanced UserAdvanced User
          61

            Apr 13, 2009#5

            Since I am doing a lot of UNIX work, I like this alot.

            Thanks,
            Steven :mrgreen: