request:find strings that are not in files of tab

Discuss and share scripts and script files...
DmFedorov
Posts: 680
Joined: 04 Jan 2011 16:36
Location: Germany

request:find strings that are not in files of tab

Post by DmFedorov »

script to search for text strings that are not in the content of files in the current tab.
For example I have a list of strings, and it is placed in a text file or in clipboard.
I need to find a list of those strings that are not in the content of files in the current tab.
As a result, it is necessary to bring these list into the box for viewing and copying.

I need such script to know that the translation strings contained in the files of folder were not deleted or changed in these files.

40k
Posts: 234
Joined: 09 Dec 2011 21:25

Re: request:find strings that are not in files of tab

Post by 40k »

Let me try something.
I develop scripts that integrate media functionality into Xyplorer.
Hash - Twitch.tv in VLC (NEW 2.0!) - FFmpeg GUI - Youtube downloading
XYplorer for Linux! Tutorial

DmFedorov
Posts: 680
Joined: 04 Jan 2011 16:36
Location: Germany

Re: request:find strings that are not in files of tab

Post by DmFedorov »

You can open any folder. Find in files of this folder 3 or 4 strings in their content, and create any strings that do not appear in the files. Then you can try.

40k
Posts: 234
Joined: 09 Dec 2011 21:25

Re: request:find strings that are not in files of tab

Post by 40k »

DmFedorov wrote:You can open any folder. Find in files of this folder 3 or 4 strings in their content, and create any strings that do not appear in the files. Then you can try.
I have an idea. Give me some time.
I develop scripts that integrate media functionality into Xyplorer.
Hash - Twitch.tv in VLC (NEW 2.0!) - FFmpeg GUI - Youtube downloading
XYplorer for Linux! Tutorial

40k
Posts: 234
Joined: 09 Dec 2011 21:25

Re: request:find strings that are not in files of tab

Post by 40k »

Code: Select all

"Findstrings"
 {
 $in = readfile('c:\in.txt', 't', , , );
 $out = writefile('c:\out.txt', '', 'o', 't');
 
 $files = get('selecteditemspathnames', '|', 'a');
 $hashes = regexmatches($in, '[^\n]+', '|', '0');
 
 foreach($file, $files, '|'){
	$content = readfile($file, 't', , , );
	writefile('c:\out.txt', "$file<crlf>", 'a', 't');
	
	foreach($hash, $hashes, '|'){
		if (regexmatches($content, $hash, '|', '0')){
			// string was found. no action required
			}
		else {
			// string was not found. adding hash to list of items
			writefile('c:\out.txt', "$hash<crlf>", 'a', 't');	
			}	
		}
	writefile('c:\out.txt', "----------------<crlf>", 'a', 't')	
	}
 text readfile('c:\out.txt', 't', , , );
 }
How it works:
1. Enter all your text strings in the text file in.txt and place it in c:\ (or update the script to the correct location with variable $in)
ONLY ONE STRING PER LINE. PUSH ENTER AFTER EVERY STRING!
2. select all the files that you want to search through in your window. you MUST select the files.
3. Script will show a text dialogue with the name of each file and the strings from in.txt that were NOT found inside your file

disclaimer: sloppy code, I haven't had my coffee yet.
I develop scripts that integrate media functionality into Xyplorer.
Hash - Twitch.tv in VLC (NEW 2.0!) - FFmpeg GUI - Youtube downloading
XYplorer for Linux! Tutorial

DmFedorov
Posts: 680
Joined: 04 Jan 2011 16:36
Location: Germany

Re: request:find strings that are not in files of tab

Post by DmFedorov »

Thank you very match. I'll try this script in an hour.

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: request:find strings that are not in files of tab

Post by highend »

- Let's you enter the strings that should not be present into a dialog box (must be separated by |)
- If you don't enter anything it'll ask for a filename which contains these strings
- Pops up a text box with all files with their missing strings
- Goes through all files in the current directory, no manual selection first (skips binary files)

Code: Select all

    $searchStrings = input("Enter the search terms...", "Terms MUST be separated by |", , "s", "empty", 600, 200);
    if ($searchStrings == "") {
        $searchStringsFile = inputfile("<curpath>", , "You did not enter any search terms, please select the file that contains them...<crlf>Terms MUST be separated by |");
        $searchStrings = readfile($searchStringsFile);
    }

    $allFiles = listfolder(, "*", 1, "|");

    $fileWithMissingString = "";
    foreach($file, $allFiles, "|") {
        if (filetype($file) != "Binary") {
            $markFile = "";
            $notFoundStrings = "";
            $fileContent = readfile($file);

            foreach($string, $searchStrings, "|") {
                if (strpos($fileContent, $string) == -1) {
                    $notFoundStrings = $notFoundStrings . $string . "|";
                    $markFile = 1;
                }
            }

            if (substr($notFoundStrings, -1) == "|") {
                $notFoundStrings = regexreplace($notFoundStrings, "\|$", "");
            }
            if ($markFile) {
                $fileWithMissingString = $fileWithMissingString . $file . " - " . $notFoundStrings . "<crlf>";
            }
        }
    }
    text $fileWithMissingString;
One of my scripts helped you out? Please donate via Paypal

40k
Posts: 234
Joined: 09 Dec 2011 21:25

Re: request:find strings that are not in files of tab

Post by 40k »

highend wrote: - Goes through all files in the current directory, no manual selection first (skips binary files)
Probably will need to exclude anything that isn't ASCII or UTF-8 encoded. However I think it's safe to assume OP will just group the files he needs beforehand so that kind of error handling isn't vital. Nice touch though.
I develop scripts that integrate media functionality into Xyplorer.
Hash - Twitch.tv in VLC (NEW 2.0!) - FFmpeg GUI - Youtube downloading
XYplorer for Linux! Tutorial

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: request:find strings that are not in files of tab

Post by highend »

However I think it's safe to assume OP will just group the files he needs beforehand
That's what I did :biggrin:

Small change (to not cancel the whole script if you press cancel on the first inputbox):

Code: Select all

    $searchStrings = input("Enter the search terms...", "Terms MUST be separated by |", , "s", "none", 600, 200);
    if ($searchStrings == "" || $searchStrings == "none") {
One of my scripts helped you out? Please donate via Paypal

DmFedorov
Posts: 680
Joined: 04 Jan 2011 16:36
Location: Germany

Re: request:find strings that are not in files of tab

Post by DmFedorov »

I need to find a list of those strings that are not in the content of files in the current tab.
-------------------------
highend and 40k
If I have for example 4 files and 3 strings:

F:\_New\inspector.js
F:\_New\NetworkPanel.js
F:\_New\ProfilesPanel.js
F:\_New\ResourcesPanel.js

You need to install a Chrome extension|Remove all DOM breakpoints|Save entry as HAR
where third string "Save entry as HAR" is missing in files, I have in box:

F:\_New\inspector.js - Save entry as HAR
F:\_New\NetworkPanel.js - You need to install a Chrome extension|Remove all DOM breakpoints|Save entry as HAR
F:\_New\ProfilesPanel.js - You need to install a Chrome extension|Remove all DOM breakpoints|Save entry as HAR
F:\_New\ResourcesPanel.js - You need to install a Chrome extension|Remove all DOM breakpoints|Save entry as HAR
-----------------------
but I must have in this case only this:

Save entry as HAR

40k
Posts: 234
Joined: 09 Dec 2011 21:25

Re: request:find strings that are not in files of tab

Post by 40k »

DmFedorov wrote:I need to find a list of those strings that are not in the content of files in the current tab.
-------------------------
highend and 40k
If I have for example 4 files and 3 strings:

F:\_New\inspector.js
F:\_New\NetworkPanel.js
F:\_New\ProfilesPanel.js
F:\_New\ResourcesPanel.js

You need to install a Chrome extension|Remove all DOM breakpoints|Save entry as HAR
where third string "Save entry as HAR" is missing in files, I have in box:

F:\_New\inspector.js - Save entry as HAR
F:\_New\NetworkPanel.js - You need to install a Chrome extension|Remove all DOM breakpoints|Save entry as HAR
F:\_New\ProfilesPanel.js - You need to install a Chrome extension|Remove all DOM breakpoints|Save entry as HAR
F:\_New\ResourcesPanel.js - You need to install a Chrome extension|Remove all DOM breakpoints|Save entry as HAR
-----------------------
but I must have in this case only this:

Save entry as HAR
That's highend's script. Can you post what is the output of mine?
I develop scripts that integrate media functionality into Xyplorer.
Hash - Twitch.tv in VLC (NEW 2.0!) - FFmpeg GUI - Youtube downloading
XYplorer for Linux! Tutorial

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: request:find strings that are not in files of tab

Post by highend »

where third string "Save entry as HAR" is missing in files
You mean: It's only missing in the file "inspector.js"...
but I must have in this case only this:

Save entry as HAR
You've said that you want the file together with the missing strings, so the output should still be:
D:\Temp\test\inspector.js - Save entry as HAR

And that's exactly what I get when I use my script on your 4 files...

Attached a small animation as a proof...
Attachments
anim.zip
(491.46 KiB) Downloaded 132 times
One of my scripts helped you out? Please donate via Paypal

40k
Posts: 234
Joined: 09 Dec 2011 21:25

Re: request:find strings that are not in files of tab

Post by 40k »

What program do you use make a gif like that highend? Looks really nice.
I develop scripts that integrate media functionality into Xyplorer.
Hash - Twitch.tv in VLC (NEW 2.0!) - FFmpeg GUI - Youtube downloading
XYplorer for Linux! Tutorial

DmFedorov
Posts: 680
Joined: 04 Jan 2011 16:36
Location: Germany

Re: request:find strings that are not in files of tab

Post by DmFedorov »

40k
With your script I receive

F:\_New\inspector.js
You need to install a Chrome extension
Remove all DOM breakpoints
Save entry as HAR
----------------
F:\_New\NetworkPanel.js
You need to install a Chrome extension
Remove all DOM breakpoints
Save entry as HAR
----------------
F:\_New\ProfilesPanel.js
You need to install a Chrome extension
Remove all DOM breakpoints
Save entry as HAR
----------------
F:\_New\ResourcesPanel.js
You need to install a Chrome extension
Remove all DOM breakpoints
Save entry as HAR
----------------

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: request:find strings that are not in files of tab

Post by highend »

40k wrote:What program do you use make a gif like that highend? Looks really nice.
It's made by GifCam (http://blog.bahraniapps.com/?page_id=21)

Resized it to 800 x 600... Looks awful... I'll remove it after the OP next answer anyway...
One of my scripts helped you out? Please donate via Paypal

Post Reply