\documentclass[a4paper]{article}
\parindent0pt

\makeatletter
\def\next{ABC}
\def\A{This is the letter A}
\newcommand{\teststrip}[1]{(Path=#1): File=(\strip{#1})}
\newcommand{\strip}[1]{{\xstrip#1/;}}
\def\xstrip#1/#2{\def\A{#2}%
  \if;\A\def\next{#1\@gobble}\else\def\next{\xstrip}\fi%
  \next#2}
\makeatother

\begin{document}
%\tracingall

\teststrip{a/f} 

We do not modify the macros outside.\\
\verb'\next'='\next'\\
\verb'\A'='\A'

\teststrip{a/b/f}

\teststrip{a/b/c//f.ps}

\teststrip{f}

\end{document}
