Open List of Files

Open List of Files

6
NewbieNewbie
6

    Dec 16, 2015#1

    I can use the right click Open to open an individual file listed in an UltraEdit document, but I can't find a way to open an entire list.

    I have generated the list externally, rather than using the Find in Files command to produce the list.

    Any suggestions very welcome.

    6,603548
    Grand MasterGrand Master
    6,603548

      Dec 16, 2015#2

      Open in help of UltraEdit via tab Index the page with title Command Line Parameters. You can read there:
      UE Help wrote:File containing list of files to be opened
      You may specify that the filename on the command line contains a list of files to open by using a /f parameter on the command line. In this case, UltraEdit will read each line of the file on the command line, and attempt to open each file. The file specified on the command line when the /f parameter is used must contain only filenames, and each filename must be on a separate line
      So you can run uedit32.exe or uedit64.exe with the parameter: /f"Name of list file with full or relative path"

      Well, if the list file itself is opened already in UltraEdit, you could use a script to open all files in active list file.

      The script code for this task would be:

      Code: Select all

      if (UltraEdit.document.length > 0)  // Is any file opened?
      {
         // Define environment for this script.
         UltraEdit.insertMode();
         if (typeof(UltraEdit.columnModeOff) == "function") UltraEdit.columnModeOff();
         else if (typeof(UltraEdit.activeDocument.columnModeOff) == "function") UltraEdit.activeDocument.columnModeOff();
      
         // Select all in active file.
         UltraEdit.activeDocument.selectAll();
      
         // Is anything selected at all?
         if (UltraEdit.activeDocument.isSel())
         {
            var sLineTerm = "\r\n";   // Default line terminator type is DOS.
            var nLineTermPos = UltraEdit.activeDocument.selection.search(/\r\n|\n|\r/);
            if (nLineTermPos >= 0)    // Any line terminator found?
            {
               // The list file is a Unix file if first character found is a line-feed.
               if (UltraEdit.activeDocument.selection[nLineTermPos] == '\n') sLineTerm = "\n";
               // The list file is a Mac file if first character found is a carriage
               // return and the next character is not a line-feed as in a DOS file.
               else if (UltraEdit.activeDocument.selection[nLineTermPos+1] != '\n') sLineTerm = "\r";
            }
            var asFileNames = UltraEdit.activeDocument.selection.split(sLineTerm);
      
            // The list is not needed anymore and can be closed now without saving.
            UltraEdit.closeFile(UltraEdit.activeDocument.path,2);
      
            // Remove empty string at end of the list caused
            // by a line termination at end of the list file.
            if (!asFileNames[asFileNames.length-1].length) asFileNames.pop();
      
            // Now open one file after the other.
            // No file in the list should be opened already on script start! Why?
            // https://forums.ultraedit.com/viewtopic.php?f=52&t=4596#p26710
            // contains the answer on point 7 and the solution to enhance
            // this script further if this is necessary in some cases.
            for (var nFileIndex = 0; nFileIndex < asFileNames.length; nFileIndex++)
            {
               UltraEdit.open(asFileNames[nFileIndex]);
            }
         }
      }
      
      This script code is taken nearly completely from Run a script on all files of a directory tree.
      Best regards from an UC/UE/UES for Windows user from Austria

      6
      NewbieNewbie
      6

        Dec 16, 2015#3

        That Sir is Superb - thank you for making my life easier!