"Remove Lines found in" "list of files / folder"

Get help with installation and running here.

Moderators: DataMystic Support, Moderators, DataMystic Support, Moderators, DataMystic Support, Moderators

Post Reply
Moz
Posts: 11
Joined: Sun Oct 09, 2005 8:15 pm

"Remove Lines found in" "list of files / folder"

Post by Moz »

I have a large number of files which contain lines I want to remove from a "file to process".

I use the "Remove lines found in" filter but I have to create multiple filters, one for each file.

Is it possible to just have one "remove lines found in" filter that either removes lines found in all files in a directory or alls for wildcards?

I tried wildcards in the filter but it didn't work like this:
Remove lines found in>fromfile>c:\files\*.txt

Thanks,

Moz
User avatar
DataMystic Support
Site Admin
Posts: 2227
Joined: Mon Jun 30, 2003 12:32 pm
Location: Melbourne, Australia
Contact:

Re: "Remove Lines found in" "list of files / folder"

Post by DataMystic Support »

Huh?

Why don't you drag and drop your files/directories to the Files to Process tab?
Moz
Posts: 11
Joined: Sun Oct 09, 2005 8:15 pm

Re: "Remove Lines found in" "list of files / folder"

Post by Moz »

Because I don't want to process those files.

I have:

"File A" <-- this is the file I want to process and it contains lots of numbers, one on each line
"file 1" <-- this contains a list of numbers
"file 2" <-- this contains a list of numbers
"file 3" <-- this contains a list of numbers

I want to remove all numbers from File A that are found in files 1-3.

i.e. I don't want to remove anything from files 1-3, just to remove numbers from File A that are found in the other files.

In reality I have lots and lots of files containing the numbers I want to remove and I'm currently having to add an extra filter for each of files 1..3.

Thanks,

Moz
User avatar
DataMystic Support
Site Admin
Posts: 2227
Joined: Mon Jun 30, 2003 12:32 pm
Location: Melbourne, Australia
Contact:

Re: "Remove Lines found in" "list of files / folder"

Post by DataMystic Support »

Save this file as a .vbs file - add as many file1...filex lines as you need. Then double-click the file in explorer - you should then have a TP filter with what you need.

Code: Select all

'The global TextPipe Application object
dim vb_TextPipeApp
'The global TextPipe Filter Window
dim vb_TPWindow


Set vb_TextPipeApp = CreateObject("TextPipe.Application")
Set vb_TPWindow = vb_TextPipeApp.newWindow

TPWindow.startFilters
TPWindow.clearAllFilters
f1 = TPWindow.addStringFilterFile( 4, "C:\file1.txt", false )
f1 = TPWindow.addStringFilterFile( 4, "C:\file2.txt", false )
f1 = TPWindow.addStringFilterFile( 4, "C:\file3.txt", false )
f1 = TPWindow.addStringFilterFile( 4, "C:\file4.txt", false )
..etc...
TPWindow.endFilters

TPWindow.clearAllFiles
TPWindow.addFile "c:\FileA.txt", 0, 1
Moz
Posts: 11
Joined: Sun Oct 09, 2005 8:15 pm

Re: "Remove Lines found in" "list of files / folder"

Post by Moz »

Hi Simon,

That's excellent! Thanks!

I had to change a couple of things in your vbscript (you'd declared vb_TPWindow but then referred to it just as TPWindow later on), and also I wanted to dynamically load the list of files which should be added to the filter. I've managed to work those out by combining your vbScript with some I found from goexpert.com, however I have four problems:

1. If textpipe isn't running and I run the VBScipt then textpipe will load a "hidden" window. i.e. it shows on windows taskbar but I am unable to see the textpipe window when I click on textpipe or alt+tab to the screen. IfI close the window by right clicking on the taskbar then textpipe says there's a new filter which hasn't been saved and would I like to save it. If textpipe is already running when I run the VBS then it works fine. Is there a way that I can run the vbs without having textpipe already running?
2. The vbs changes the input to "input from clipboard" - how do I change this to input from file?
3. The vbs changes the output to "output to clipboard" how do I change this to "Files output" and also change the output folder?
4. When I try and close Textpipe after running the vbs I get an error "There are still active COM objects in this application. etc etc. Are you sure you want to close this application?" If I select Yes then textpipe still stays on the taskbar until I eventually receive an application Error "Exception EAccessViolation in modile textpipe.exe at <<changing number here>>/ etc etc".

I've had a good look through the very extensive help files but couldn't work out what VB commands could set the input / output to files instead of clipboard.

Here's my code for dynamically pulling the files to add to the filter:

Code: Select all

On Error Resume Next
  Dim fso, folder, files, NewsFile,sFolder
  Dim TextPipeApp
  Dim TPWindow

  Set fso = CreateObject("Scripting.FileSystemObject")
 
  'Folder where the files to load in the filter will be
  sFolder = "c:\Users\Admin\Desktop\Textpipe\toremove\"
  Set folder = fso.GetFolder(sFolder)
  Set files = folder.Files
  
  Set TextPipeApp = CreateObject("TextPipe.Application")
  Set TPWindow = TextPipeApp.newWindow
  TPWindow.startFilters
  TPWindow.clearAllFilters
  
  For each folderIdx In files
	  f1 = TPWindow.addStringFilterFile( 4, sFolder&folderIdx.Name, false )
  Next
  TPWindow.endFilters
  
  TPWindow.clearAllFiles
  TPWindow.addFile "C:\Users\Admin\Desktop\Textpipe\toprocess\filetoprocess.txt", 0, 1
As always thanks for the helpful support!

David
User avatar
DataMystic Support
Site Admin
Posts: 2227
Joined: Mon Jun 30, 2003 12:32 pm
Location: Melbourne, Australia
Contact:

Re: "Remove Lines found in" "list of files / folder"

Post by DataMystic Support »

Thanks for picking up the discrepancy - we will fix that. The code is generated from TextPipe's FIle Menu\Export\VBScript menu item. You will find a lot of what you need by playing with that.

1 -

Code: Select all

vb_TextPipeApp.visible = true
2.

Code: Select all

TPWindow.inputMode = 1
3.

Code: Select all

TPWindow.outputMode = 1
TPWindow.outputFolder = "C:\blah"
4.

Code: Select all

sub vb_disconnectTextPipe()

  if isObject( vb_TPWindow ) then
    vb_TPWindow.closeWithoutSave
    Set vb_TPWindow = Nothing
  end if

  if isObject( vb_TextPipeApp ) then
    Set vb_TextPipeApp = Nothing
  end if

end sub
Moz
Posts: 11
Joined: Sun Oct 09, 2005 8:15 pm

Re: "Remove Lines found in" "list of files / folder"

Post by Moz »

Thanks for these fixes. They all work perfectly apart from number 4. I still get an error when closing textpipe after running the filter.
The errors I get (in order) are like this (sometimes different address numbers):
  • Access violation at address 00397993 in module textpipe.exe. Read of address 00000000.
    Access violation at address 0004EF7E in module textpipe.exe. Read of address 00000000.
    Access violation at address 0004EF7E in module textpipe.exe. Read of address 00000000.
    Access violation at address 0001366C in module textpipe.exe. Read of address FFFFFFFC.
    Access violation at address 00032DF3 in module textpipe.exe. Read of address 00000000.
Then I get a blank error dialog where the button has no text and I'm then unable to close the dialog or textpipe, however I can kill textpipe using the taskman and this error goes away.

This is at the end of my code:

Code: Select all

  Set TPWindow = Nothing
  TPWindow.closeWithoutSave
  Set TextPipeApp = Nothing
I noticed that although I have "TPWindow.closewithoutSave" this doesn't actually close my filter. I tried closewithoutsave() as well after looking at http://www.datamystic.com/textpipe/com_interface.html .

I'm using Win 7 x64.Textpipe version 8.7

Any ideas?

Moz
User avatar
DataMystic Support
Site Admin
Posts: 2227
Joined: Mon Jun 30, 2003 12:32 pm
Location: Melbourne, Australia
Contact:

Re: "Remove Lines found in" "list of files / folder"

Post by DataMystic Support »

Just use:

Code: Select all

      Set TPWindow = Nothing
      Set TextPipeApp = Nothing
Post Reply