Find a File on HDD then Open in UE

Find a File on HDD then Open in UE

2

    Nov 24, 2010#1

    Hey Everybody,

    i spend a lot of time on this forum to find a solution to my problem, but until yet, without any success.

    Is it possible to search for a file in a specified Directory (including Subfolders) and after that, open the founded file?
    Limitation:
    - won't parse the Search Result Window
    - won't modify the local Clipboard

    Thanks in Advance,
    Fireball

    6,683583
    Grand MasterGrand Master
    6,683583

      Nov 24, 2010#2

      Normally it is best to search with a file manager (Windows Explorer, if you don't have something better) for files and open the found file (or files) of interest in UltraEdit.

      However, you can do this simple "find file and open" task also from within UltraEdit. Click on File - Quick Open. The path of the active file is used as start directory. With Open all matching files from subdirectories enabled UltraEdit searches also in all subdirectories within the active working directory. You can enter the file name or a wildcard string. Quick open is a very handy feature to open one or more files stored anywhere in a project tree.
      Best regards from an UC/UE/UES for Windows user from Austria

      2

        Nov 25, 2010#3

        Thanks for your reply.
        I've tested the quick open function also, but the base directory is the path of the active file, like you said.
        My project structure is the following:

        C:\Project
        C:\Project->Folder1->DialogSources->*.*
        C:\Project->Folder1->FunctionSources->*.*
        C:\Project->Folder2->DialogSources->*.*
        C:\Project->Folder2->FunctionSources->*.*
        C:\Project->Folder3->DialogSources->*.*
        C:\Project->Folder3->FunctionSources->*.*

        1. If have an open file which locate in "Project->Folder1->DialogSources",
        2. now I wan't to open a file from "Project->Folder3->FunctionSources",
        3. the Directory in the quick open dialog is Project->Folder1->DialogSources because there's the active file.

        All my problems would dissolve in air if I would be able to indicate a fix path in the quick open dialog. (In my case: "C:\Project".)
        But this is not posslible, correct?

        thanks in advance,
        fireball

        6,683583
        Grand MasterGrand Master
        6,683583

          Nov 26, 2010#4

          Yes, the quick open dialog always uses the path of the active document as starting directory and it is not possible to configure the directory. Most users of UltraEdit working with projects use the Project tab of the File Tree View or the Project Settings dialog to open a file from the project. UEStudio has additional commands for quickly open a project file.

          However, to help you with your requirement on quick file open I wrote a small script to do this task.

          Code: Select all

          var sFilename = "";
          // getString to variable is not working if no document window open.
          if (UltraEdit.document.length < 1) {
             UltraEdit.newFile();
             sFilename = UltraEdit.getString("Enter name of file(s) to open:",1);
             UltraEdit.closeFile(UltraEdit.activeDocument.path,2);
          } else {
             sFilename = UltraEdit.getString("Enter name of file(s) to open:",1);
          }
          
          if (GetListOfFiles(0,"C:\\Project\\",sFilename,true)) {
             var nListFile = GetFileIndex();
             while (UltraEdit.document[nListFile].isEof() == false) {
                UltraEdit.document[nListFile].startSelect();
                UltraEdit.document[nListFile].key("END");
                sFilename = UltraEdit.document[nListFile].selection;
                UltraEdit.document[nListFile].endSelect();
                UltraEdit.document[nListFile].key("HOME");
                UltraEdit.document[nListFile].key("DOWN ARROW");
                var nFileToOpen = GetFileIndex(sFilename);
                if (nFileToOpen < 0) UltraEdit.open(sFilename);
                else UltraEdit.document[nFileToOpen].setActive();
             }
             UltraEdit.closeFile(UltraEdit.document[nListFile].path,2);
          }
          You have to include additionally the script code for the functions GetListOfFiles and GetFileIndex. And you have to change the string "C:\\Project\\" to path of your project directory. (There is no variable containing the project directory path as defined in the project settings dialog.)

          Add this script to Scripting - Script List and assign a hotkey to the script for fast executing it.

          You should also uncheck Show status information in output window at Advanced - Configuration - Scripting to avoid loosing the content of active output window on every execution of this script.
          Best regards from an UC/UE/UES for Windows user from Austria