TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a function which takes a filepath as an argument. How can I extract the basename (file.c in the example below) from the argument?



share|improve this question
up vote 12 down vote accepted

LaTeX includes a filepath parser (the exact syntax it parses depends on the system)



\typeout{area: \filename@area}

\typeout{name: \filename@base}

\typeout{ext: \filename@ext}


Produces this on the terminal:

area: path/to/
name: file
ext: c
share|improve this answer
Works beautifully. Thanks! – Roberto Aloi Jul 31 '12 at 13:52

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.