RSS

 
WinEdt Macro Library  | text previous macro  | next macro

getRelativeFilePath

Extracts the relative Path to %P

Description

Choosing a file with the file browser, this macro extracts the Relative Path to the current working directory %P and inserts it in the text.

You can limit moving upwards with "../" to a specific number of nodes at the end of the macro (default is 3).
The macro checks, whether the two paths (current dir and browsed filepath) are on different drives.
In these both cases, the absolute path will be inserted. Filenames are always converted to UNIX style (at the end of the macro)!

The macro can be used in combination with Active Strings like fileref="?" (DocBook mode), \input{?} (TeX mode), or src="?" (HTML mode).

The job of comparing the two filepaths is assisted by the tokenizer macro.

Installation

Save the file in %b\Macros\text\, and assign a shortcut to it if you want.

You also need the macro macro\tokenizer.edt, which you already have if you've downloaded the complete WinEdt Macro Library.

Download

text/getRelativeFilePath.edt

macro/tokenizer.edt

Macro contributed by Georges Schmitz <georges.schmitzheitec.de>.

WinEdt Macro Library  | text previous macro  | next macro