User to user discussion and support for UltraEdit, UEStudio, UltraCompare, and other IDM applications.

Help with writing and running scripts
3 posts Page 1 of 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.
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();
   UltraEdit.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://www.ultraedit.com/forums/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 Austria
That Sir is Superb - thank you for making my life easier!
3 posts Page 1 of 1
cron