[TxMt] Re: Create command that deletes a file [first replacing the extension]?
Martin Kühl
martin.kuehl at gmail.com
Sat Jun 12 20:41:52 UTC 2010
On Sat, Jun 12, 2010 at 21:02, Marius Hofert <m_hofert at web.de> wrote:
> I have a file with a certain extension. In the folder where this file is located, there is a file with the same name but extension .pdf. How do I create a command that removes the .pdf?
> My first trial was this (bundle editor):
> 1) Save: Current File
> 2) Command(s): rm "$TM_FILENAME/Rd/pdf"
> 3) Input: None
> 4) Output: Discard
> So I guess 2) is the problem. How can I replace the file extension by .pdf?
Try this:
rm "${TM_FILEPATH/%Rd/pdf}"
* The braces are part of the shell syntax for pattern replacement.
* Prefixing the pattern with `%` makes sure it only matches the end of
the expanded string.
* $TM_FILENAME contains just the `basename` of the current file, use
$TM_FILEPATH for its absolute path.
HTH,
Martin
More information about the textmate
mailing list