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.
Replacing fragments in the text by an enumerator
Moderators: DataMystic Support, Moderators, DataMystic Support, Moderators, DataMystic Support, Moderators
-
- Posts: 11
- Joined: Thu Apr 26, 2012 11:57 pm
- DataMystic Support
- Site Admin
- Posts: 2227
- Joined: Mon Jun 30, 2003 12:32 pm
- Location: Melbourne, Australia
- Contact:
Re: Replacing fragments in the text by an enumerator
This is quite simple.
First, add a perl pattern filter, with pattern of
and Action - send variable 1 to subfilter.
Inside this filter, add a Filters\Special\Script (VBScript,JScript...), with the text below:
First, add a perl pattern filter, with pattern of
Code: Select all
Perl pattern [image_(\d+)\.jpg]
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
-
- Posts: 11
- Joined: Thu Apr 26, 2012 11:57 pm
Re: Replacing fragments in the text by an enumerator
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
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
- DataMystic Support
- Site Admin
- Posts: 2227
- Joined: Mon Jun 30, 2003 12:32 pm
- Location: Melbourne, Australia
- Contact:
Re: Replacing fragments in the text by an enumerator
Happy to complete this task for you with a purchase of TextPipe Pro, or of consulting time if you are an existing customer.