[TxMt] converting and merging files through TM

Robin Houston robin.houston at gmail.com
Wed Oct 3 17:39:49 UTC 2007


On 03/10/2007, Jamal Shahin <jshahin at gmail.com> wrote:
> 2. the numbering system I used for the files was based on a primary
> key from our database, but I've been asked to renumber all the files
> starting from 1 (for a silly reason, the database started with a
> primary key of 67, and manually-entered records start at 400.). *Is
> there any way that I can use TM to convert "##number ##" into "##
> incremental number ##"?* e.g. in find and replace, use:
> find: ##(\d*)\w? ## (the \w? is there as a couple of documents are
> labelled like: 137a)
> replace: ##(x+1) ##
>
> It's the (x+1) that's bothering me.

You can do this easily enough using a one-line Perl script, as follows.

1. Choose "Filter through command…" from the Text menu, or press apple-option-R.
2. Choose Input: Document, and Output: Replace document.
3. For the command, put the following:

  perl -le 's/##\d+\w? ##/++$n/eg'


That will convert your numbers to 1, 2, 3, 4, etc. in order, which is
what I think you want.

Robin



More information about the textmate mailing list