Replacing fragments in the text by an enumerator

Get help with installation and running here.

Moderators: DataMystic Support, Moderators

shveicar980
Posts: 11
Joined: Thu Apr 26, 2012 11:57 pm

Replacing fragments in the text by an enumerator

Postby shveicar980 » Thu Nov 29, 2012 8:11 pm

Hello!
Tell me how to make the replacement of every meeting in html file type values image_3453.jpg to the value image_(enumerator).jpg
For example:
Searching - scheme image_ ([0-9] +). jpg replace the first value encountered in the text to image_001.jpg, replacing the second value encountered in the text to image_002.jpg, replacing the third value encountered in the text to image_003. jpg and so on.
For example there is a parameter [C]-enumerator in the program totalcommander but this program only works with file names.Perhaps provides commands for such cases in your program.
Thank you very much.

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

Re: Replacing fragments in the text by an enumerator

Postby DataMystic Support » Fri Nov 30, 2012 8:46 am

This is quite simple.

First, add a perl pattern filter, with pattern of

Code: Select all

Perl pattern [image_(\d+)\.jpg]

and Action - send variable 1 to subfilter.

Inside this filter, add a Filters\Special\Script (VBScript,JScript...), with the text below:

Code: Select all

      'Our line counter
      dim a
     
      'Called for every line in the file
      'EOL contains the end of line characters (Unix, DOS or Mac) that must be
      'appended to each line
      function processLine(line, EOL)
        a = a + 1
        processLine = a & EOL
      end function
     
     
      sub startJob()
        a = 0
      end sub
     
     
      sub endJob()
      end sub
     
     
      'Called before each file is opened -
      'perform per-file initialisation here
      function startFile()
        startFile = ""
      end function
     
     
      function endFile()
        endFile = ""
      end function
   
Regards,

Simon Carter, http://DataMystic.com/forums/index.php
http://PredictBGL.com - Insulin dose calculator for Type 1 diabetes
http://DownloadPipe.com - 250,000 free software downloads
http://DetachPipe.com - send huge email attachments

shveicar980
Posts: 11
Joined: Thu Apr 26, 2012 11:57 pm

Re: Replacing fragments in the text by an enumerator

Postby shveicar980 » Fri Nov 30, 2012 8:06 pm

Thanks for the help,but the numbering of the counter starts with 1 -
fragments derived form image_1.jpg image_2.jpg
What do I need do - to numbering was kind 001, 002 - that is image001.jpg image002.jpg and so on.I tried to change the parameter a = 0 for a = "000" still get the same result.
Obtained for all the files - one counter in your example.How to do so - to each individual file that has been added to the list of processing would be its own counter.
Thank you very much

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

Re: Replacing fragments in the text by an enumerator

Postby DataMystic Support » Sat Dec 01, 2012 12:18 pm

Happy to complete this task for you with a purchase of TextPipe Pro, or of consulting time if you are an existing customer.
Regards,

Simon Carter, http://DataMystic.com/forums/index.php
http://PredictBGL.com - Insulin dose calculator for Type 1 diabetes
http://DownloadPipe.com - 250,000 free software downloads
http://DetachPipe.com - send huge email attachments


Return to “TextPipe Tips and Tricks, Questions and Support”

Who is online

Users browsing this forum: No registered users and 3 guests