Tapatalk

verify existence of a string in several files

verify existence of a string in several files

3
NewbieNewbie
3

    Sep 29, 2006#1

    Hi.

    I'd like to verify the existence of a certain string (a copyright string) in a set of cpp,c,h files underneath a subdirectory and get a list of all such files lacking such a string so I can go put one in.

    Can someone recommend an approach?

    I did fire up a find in files but I'm not sure how to hook in an 'if not found log to a message file/screen and continue" function.

    Thanks
    Jeff

    6,685587
    Grand MasterGrand Master
    6,685587

      Sep 29, 2006#2

      Well, this is a hard job for UltraEdit. My Windows Explorer replacement tool Total Commander is capable for searching in *.cpp;*.h;*.c files in one or more specified directories including subdirectories which does NOT contain a specified string.

      If you want to do it with an UltraEdit macro, you first have to run a FindInFiles with a search string which is found in all your files (for example the space if you don't have a string which is not so often found) with results to an edit window. Then remove everything from the result except the file names with full path to get a file which contains all filenames with *.cpp;*.c;*.h in the specified directory and below.

      At Send all open file names to tool I have posted such a "Get File List" macro, but it's not working anymore for UltraEdit v12.00 and above because of some bugs (since UE 12.00 the result file is an Unicode file and finds+replaces and the sort are not working properly on Unicode files and there is also a focus problem with FindInFiles with parameter Log). I have in my emails to IDM storage a macro which works for all versions of UE because it has many extra codes as workarounds for the known bugs. I can post it if you are interested in.

      Next you need a second FindInFiles searching in the same files but now for the copyright string. Also the result of this search is logged to an edit window and again everything except the file names must be removed from this result file.

      The last part of the macro know removes the file names from the second search in the result list of the first search. What you get is a list of files which does not contain the copyright string.

      The idea is quite simply but the implementation is very hard because of many UE bugs with FindInFiles and Unicode handling and especially if the macro should be also independet of the version of UltraEdit and UEStudio.

      Maybe when I have time I will write a macro for general usage of "Find files which do NOT have a specified string".

      But the usage of Total Commander for this job is MUCH MUCH easier and faster.
      Best regards from an UC/UE/UES for Windows user from Austria

      3
      NewbieNewbie
      3

        Sep 29, 2006#3

        Thanks for the reply. At least I know what I should be looking for.
        I guess I'll crank up the old scripting language and beat out a script.

        thanks much!
        p.s. if you want to post that script you had, I always benefit seeing how things are/can be done.

        regards

        344
        MasterMaster
        344

          Sep 29, 2006#4

          Hi Jeff, hi Mofi,

          Yes, don't take a Camel for flying (ok, this is unfair ... UE ain't a camel).

          I searched the web and found a small search-tool called XSearch that is free and needs no installation:

          http://www.easexp.com/

          There you can specify a file-filter and a search word, with the option "not containing search word".
          I figured it out and it seems to work :-)
          Results can be saved and the easily manipulated by Camel - öh - UE.
          No guarantee anyway !

          hih, holdriöh, Bego
          Normally using all newest english version incl. each hotfix. Win 10 64 bit