Select files that does not have some text

This is a place for users to discuss Altap Salamander. Please feel free to ask, answer questions, and express your opinion. Please do not post problems, bug reports or feature requests here.
docfxit
Posts: 76
Joined: 02 May 2006, 23:51

Select files that does not have some text

Post by docfxit »

I'd like to find out how to select all files that do not have the following text:
<ToReturnCode>31
in the file.

I'd like to have them in either the left or right side of Salamander.

Thank you,

Docfxit
therube
Posts: 674
Joined: 14 Dec 2006, 06:22

Re: Select files that does not have some text

Post by therube »

Finding should be easy.

The "!" is a NOT operator.
So something like "!<ToReturnCode>31" ? (You may need to escape the brackets?)

That should provide you with the list of file names that you want.

Next part is harder ...?

Perhaps if you said what your intentions are with the found files?

Perhaps ...

Can the names (& or path/names) be sent to a list?
Or dragged to another application that would accept the names - as a list (rather then a file), such as a file name renamer. And with that you could add something unique to the names, like a prefix of "XXX-". Salamander would see that change. The files in question would be obvious & sortable ...
WinXP Pro SP3 or Win7 x86 | SS 2.54
User avatar
Ether
Posts: 1471
Joined: 10 May 2007, 16:08
Location: Czech Republic
Contact:

Re: Select files that does not have some text

Post by Ether »

Find the files using Find, make a list of those files (you just need to substitute $(FullName) with $(Name) , copy the list to the clipboard and then Edit > Advanced > Load Selection... and Edit > Invert Selection.
Ελληνικά rulez.
docfxit
Posts: 76
Joined: 02 May 2006, 23:51

Re: Select files that does not have some text

Post by docfxit »

therube wrote:Finding should be easy.

The "!" is a NOT operator.
So something like "!<ToReturnCode>31" ? (You may need to escape the brackets?)

That should provide you with the list of file names that you want.
Thank you for the reply.

Let's start with the easy part.
When I use "!<ToReturnCode>31" without the quotes in the Containing field I get no files.
When I use "!31" I get no files.
When I use "ToReturnCode>32" I get lots of files. (If there is a 32 there wouldn't be a 31 so all these files and more should show when I use "!31")
I'm not sure how to escape the brackets.
When I use "^!<ToReturnCode>31" I get no files.
When I use "!^<ToReturnCode>31" I get no files.
When I use "^!^<ToReturnCode^>31" I get no files.
When I use "^!31" I get no files.
When I use "!^31" I get no files.

I'm using ver. 2.54
A typical file looks like this:

Code: Select all

- <DAZzle Layout="C:\Programs\DAZzle\Envelope4300.lyt" OutputFile="M:\Results\Test.XML" Start="PRINTING" Test="No" Prompt="NO" AutoClose="YES">
- <Package ID="1">
  <MailClass>FIRST</MailClass> 
  <DateAdvance>0</DateAdvance> 
  <PackageType>ENVELOPE</PackageType> 
  <Oversize>FALSE</Oversize> 
  <WeightOz>1</WeightOz> 
  <Width>4</Width> 
  <Length>9.5</Length> 
  <Depth>.1</Depth> 
  <Services>CertifiedMail="OFF" DeliveryConfirmation="Off"</Services> 
  <Value>0.00</Value> 
  <Description>Correspondence</Description> 
  <ReferenceID>0038005</ReferenceID> 
  <ToEmail>Sample@notreal.org</ToEmail> 
  <ToZIP4>7564</ToZIP4> 
  <ToDeliveryPoint>99</ToDeliveryPoint> 
  <ToCarrierRoute>C051</ToCarrierRoute> 
  <ToReturnCode>32</ToReturnCode> 
  <PIC>00040000745025535127</PIC> 
  <FinalPostage>0.44</FinalPostage> 
  <TransactionID>3593</TransactionID> 
  <TransactionDateTime>20101102132448</TransactionDateTime> 
  <PostmarkDate>20101102</PostmarkDate> 
  <Status>Success</Status> 
  </Package>
  </DAZzle>
Any ideas?

Thank you,

Docfxit
Jan Patera
Plugin Developer
Plugin Developer
Posts: 707
Joined: 08 Dec 2005, 14:33
Location: Prague, Czech Republic
Contact:

Re: Select files that does not have some text

Post by Jan Patera »

docfxit wrote:I get no files.
Not mentioned above, therefore double-checking: did you check the "Regular expression" checkbox?
therube
Posts: 674
Joined: 14 Dec 2006, 06:22

Re: Select files that does not have some text

Post by therube »

Sorry about that, I was wrong.

! is not NOT.
When I was testing, my initial search string was found in my file list. When I (what I thought) was "not'ing" it, so !string, it was not in any of the files, so returned nothing. I (unfortunately & incorrectly) took that to mean it was working as I expected, but it was not.

Now can you negate a R/E search string ...? Kind of getting beyond my capabilities if you can? And thinking it still will not return your expected results.


I think the problem is that when you (I) are looking for the negated string ("NOT.string), if found, we then expect the search to kick out & to not include that file in the list.

But what it actually is doing is finding other characters in the file that are not your NOT.string, & it is those that will cause the file to be in the list regardless. IOW, if the file only contained your NOT.string, & nothing else, then finding NOT.string would cause the file to not be listed (I think).
WinXP Pro SP3 or Win7 x86 | SS 2.54
therube
Posts: 674
Joined: 14 Dec 2006, 06:22

Re: Select files that does not have some text

Post by therube »

A (command line) UNIX-like "grep" can do it easily.

ftp://ftp.delorie.com/pub/djgpp/current ... rep27b.zip

Code: Select all

grep.exe  -L  "<ToReturnCode>31"  *
Where -L is ...

Code: Select all

  -L, --files-without-match  print only names of FILEs containing no match

A (small, free, standalone) GUI grep, AstroGrep has a "Negation" option.
WinXP Pro SP3 or Win7 x86 | SS 2.54
Jan Rysavy
ALTAP Staff
ALTAP Staff
Posts: 5229
Joined: 08 Dec 2005, 06:34
Location: Novy Bor, Czech Republic
Contact:

Re: Select files that does not have some text

Post by Jan Rysavy »

Ether wrote:Find the files using Find, make a list of those files (you just need to substitute $(FullName) with $(Name) , copy the list to the clipboard and then Edit > Advanced > Load Selection... and Edit > Invert Selection.
This is good solution. Just use Commands > Find Files and Directories command. Set the Search file content option and enter your string "<ToReturnCode>31" (without quotes) into the Containing field.
therube
Posts: 674
Joined: 14 Dec 2006, 06:22

Re: Select files that does not have some text

Post by therube »

Though he is looking for files that do NOT contain the search string.
WinXP Pro SP3 or Win7 x86 | SS 2.54
User avatar
Ether
Posts: 1471
Joined: 10 May 2007, 16:08
Location: Czech Republic
Contact:

Re: Select files that does not have some text

Post by Ether »

therube wrote:Though he is looking for files that do NOT contain the search string.
Yeah, but he cares only about the selection of files in the panel, not in the way of obtaining it. After you import the list of found files and invert selection, you get the correct set of files.
therube wrote:A (command line) UNIX-like "grep" can do it easily.
That is also a good solution, but since I'm not familiar with grep's syntax, I went with the Find & batch file method.
Ελληνικά rulez.
docfxit
Posts: 76
Joined: 02 May 2006, 23:51

Re: Select files that does not have some text

Post by docfxit »

Thank you all for your great suggestions.

To make it easier for the next person, I'm going to try to put what I did in one reply.

I chose to create the list of files I don't want directly into the clipboard.
I set up a user command:
Define new command in Salamander Options > Configuration > User Menu.
Name "Put List of Files in Find to the clipboard" (without the quotes).
Command: echo
Arguments: $(Name)>>"$[TEMP]\file_list.txt" && clip < "$[TEMP]\file_list.txt"
turn off the Open shell windows option.

Because I'm running in XP (that doesn't have the clip.exe file) I downloaded the clip.exe file from:
ftp://ftp.microsoft.com/Services/TechNe ... E/CLIP.EXE
I copied clip.exe to my C:\Windows\system32.

In the find window I selected all the files that I didn't want.
"<ToReturnCode>31" (without the quotes)

Then I selected all items in the Find windows (Ctrl+A), open User Menu (F9) and selected "Put List of Files in Find to the clipboard"
I had to wait a long time for it to finish. It doesn't give you any notice when it's done.
I went back to Salamander, selected the correct pane, Edit > Advanced > Load Selection... and Edit > Invert Selection.
I copied the selected files to the opposite pane.

I ended up with the files I wanted. All files without "<ToReturnCode>31"

That turned out great. I had no idea it could be done in Salamander.

Thanks a bunch,

Docfxit
therube
Posts: 674
Joined: 14 Dec 2006, 06:22

Re: Select files that does not have some text

Post by therube »

Yeah, but he cares only about the selection of files in the panel, not in the way of obtaining it. After you import the list of found files and invert selection, you get the correct set of files.
Oh, I see now. You're right :-).
WinXP Pro SP3 or Win7 x86 | SS 2.54
Post Reply